Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion pkg/sink/codec/debezium/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ type dbzCodec struct {
nowFunc func() time.Time
}

// truncateValueForLog truncates large values to avoid log flooding.
// Returns the original value if it's small enough, otherwise returns a truncated string representation.
func truncateValueForLog(value interface{}, maxLen int) interface{} {
switch v := value.(type) {
case []byte:
if len(v) > maxLen {
return fmt.Sprintf("%s... (truncated %d bytes)", string(v[:maxLen]), len(v))
}
case string:
if len(v) > maxLen {
return fmt.Sprintf("%s... (truncated %d chars)", v[:maxLen], len(v))
}
}
return value
}

func (c *dbzCodec) writeDebeziumFieldValues(
writer *util.JSONWriter,
fieldName string,
Expand All @@ -56,7 +72,12 @@ func (c *dbzCodec) writeDebeziumFieldValues(
colx := model.GetColumnDataX(col, tableInfo)
err = c.writeDebeziumFieldValue(writer, colx, colInfos[i].Ft)
if err != nil {
log.Error("write Debezium field value meet error", zap.Error(err))
log.Error("failed to write Debezium field value",
zap.String("schema", tableInfo.GetSchemaName()),
zap.String("table", tableInfo.GetTableName()),
zap.String("column", colx.GetName()),
zap.Any("value", truncateValueForLog(col.Value, 1024)),
zap.Error(err))
break
}
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/sink/codec/encoder_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@ func (g *encoderGroup) runEncoder(ctx context.Context, idx int) error {
for _, event := range future.events {
err := encoder.AppendRowChangedEvent(ctx, future.Key.Topic, event.Event, event.Callback)
if err != nil {
log.Error("encode row changed event failed",
zap.String("namespace", g.changefeedID.Namespace),
zap.String("changefeed", g.changefeedID.ID),
zap.String("schema", event.Event.TableInfo.GetSchemaName()),
zap.String("table", event.Event.TableInfo.GetTableName()),
zap.Uint64("commitTs", event.Event.CommitTs),
zap.Error(err))
return errors.Trace(err)
}
}
Expand Down