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

barrier(ticdc): fix wrong barrier ts under frequent ddl scenario (#10669) #10726

Merged
Merged
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
15 changes: 14 additions & 1 deletion cdc/owner/ddl_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,20 @@ func (m *ddlManager) barrier() *schedulepb.BarrierWithMinTs {
// barrier related physical tables
ids := getRelatedPhysicalTableIDs(ddl)
for _, id := range ids {
tableBarrierMap[id] = ddl.CommitTs
// The same physical table may have multiple related ddl events when calculating barrier.
// Example cases:
// 1. The logical id of the same partition table may change after change partition.
// So the related ddls may be considered for different tables.
// And they may be returned by `getAllTableNextDDL` at the same time.
// 2. The result of `getAllTableNextDDL` may influence the same physical tables as `ddlManager.justSentDDL`.
// So we always choose the min commitTs of all ddls related to the same physical table as the barrierTs.
if ts, ok := tableBarrierMap[id]; ok {
if ddl.CommitTs < ts {
tableBarrierMap[id] = ddl.CommitTs
}
} else {
tableBarrierMap[id] = ddl.CommitTs
}
}
}
}
Expand Down
Loading