fix(mysql): avoid unsafe inactive offset checkpoints - #4658
Conversation
The inactive-offset checkpoint skipped writing while schema deltas were pending, but deltas are only applied after the batch ends and an empty batch has no bound, so a DDL on an idle mirror could freeze the offset indefinitely. Persist the offset in the empty-batch path after ReplayTableSchemaDeltas and applySchemaDeltas succeed, and end the empty batch as soon as deltas are pending so that path is reached promptly. Zero-value checkpoints are skipped because last_text has no monotonicity guard in the catalog. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ilidemi
left a comment
There was a problem hiding this comment.
Reviewing something like this requires rebuilding a full mental model of how pull-sync-normalize works, and when are batches considered done to checkpoint on the source vs in PeerDB bookkeeping. This is at the core of CDC processing so needs to be approached carefully and holistically. Could you add a refresher/description for before vs after into the PR description?
|
Thinking about this bug:
For mysql, in the happy path, we never close the pullRecord batch until we receive at least one message, however if there is a context cancellation caused by an error or user pausing the pipe, it certainly sounds feasible that we could lose the DDL as we'd have advanced the offset. So the bug is specific to mysql. We should add an e2e test to reproduce the bug, example: execute add column ddl -> wait for sync interval to pass -> pause the pipe -> resume the pipe -> insert a row with the added column -> check if the added column got persisted to clickhouse.
|
Problem
We always advance the offset when there is no records and we've got a timeout from MySQL binlog reader. It's wrong, because there could be schema changes that we haven't persisted yet.
Solution