Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DNM] consumer(ticdc): remove order message #11812

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add more logs
  • Loading branch information
3AceShowHand committed Nov 28, 2024
commit 7426af01c14778c7bc35c168c0e7d08d7e6dea48
33 changes: 19 additions & 14 deletions pkg/sink/kafka/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,16 @@ func (p *saramaAsyncProducer) Close() {
}()
}

type item struct {
tableID string
commitTs string
offset int64
}

func (p *saramaAsyncProducer) AsyncRunCallback(
ctx context.Context,
) error {
var (
oldOffset int64
oldTableID string
oldCommitTs string
)
memo := make(map[int32]item)
for {
select {
case <-ctx.Done():
Expand All @@ -244,17 +246,20 @@ func (p *saramaAsyncProducer) AsyncRunCallback(
}
tableID := string(ack.Headers[0].Value)
commitTs := string(ack.Headers[1].Value)
previous := memo[ack.Partition]
log.Info("async producer receive ack",
zap.Int64("oldOffset", oldOffset), zap.String("tableID", oldTableID), zap.String("commitTs", oldCommitTs),
zap.Int64("newOffset", ack.Offset), zap.String("tableID", tableID), zap.String("commitTs", commitTs))
if ack.Offset < oldOffset {
log.Panic("kafka async producer receive an out-of-order message",
zap.Int64("oldOffset", oldOffset), zap.String("tableID", oldTableID), zap.String("commitTs", oldCommitTs),
zap.Int64("newOffset", ack.Offset), zap.String("tableID", tableID), zap.String("commitTs", commitTs))
zap.Int64("oldOffset", previous.offset), zap.String("oldCommitTs", previous.commitTs), zap.String("oldTableID", previous.tableID),
zap.Int64("newOffset", ack.Offset), zap.String("commitTs", commitTs), zap.String("tableID", tableID))
if ack.Offset < previous.offset {
log.Warn("kafka async producer receive an out-of-order message",
zap.Int64("oldOffset", previous.offset), zap.String("oldCommitTs", previous.commitTs), zap.String("oldTableID", previous.tableID),
zap.Int64("newOffset", ack.Offset), zap.String("commitTs", commitTs), zap.String("tableID", tableID))
}
memo[ack.Partition] = item{
tableID: tableID,
commitTs: commitTs,
offset: ack.Offset,
}
oldOffset = ack.Offset
oldTableID = tableID
oldCommitTs = commitTs
}
case err := <-p.producer.Errors():
// We should not wrap a nil pointer if the pointer
Expand Down
Loading