Skip to content

Commit

Permalink
[MongoDB] Adding warning before removing (#924)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 authored Sep 20, 2024
1 parent 27ec948 commit 0cfeb12
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/cdc/mongo/debezium.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package mongo
import (
"encoding/json"
"fmt"
"log/slog"
"reflect"
"time"

Expand Down Expand Up @@ -175,8 +176,16 @@ func (s *SchemaEventPayload) GetData(pkMap map[string]any, tc kafkalib.TopicConf
retMap = s.Payload.afterMap
// We need this because there's an edge case with Debezium
// Where _id gets rewritten as id in the partition key.
for k, v := range pkMap {
retMap[k] = v
for key, value := range pkMap {
retData, isOk := retMap[key]
if !isOk {
slog.Warn("key not found in retMap", slog.String("key", key), slog.Any("retData", retData))
} else if retData != value {
slog.Warn("value mismatch", slog.String("key", key), slog.Any("value", value), slog.Any("retData", retData))
}

// TODO: Preserve behavior.
retMap[key] = value
}

retMap[constants.DeleteColumnMarker] = false
Expand Down

0 comments on commit 0cfeb12

Please sign in to comment.