Skip to content

Commit

Permalink
barrier(ticdc): fix wrong barrier ts under frequent ddl scenario (pin…
Browse files Browse the repository at this point in the history
  • Loading branch information
lidezhu authored and ti-chi-bot committed Mar 6, 2024
1 parent a3c5d02 commit 612ecd8
Showing 1 changed file with 14 additions and 1 deletion.
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

0 comments on commit 612ecd8

Please sign in to comment.