zhangshenghang opened a new issue, #13648: URL: https://github.com/apache/seatunnel/issues/13648
### Search before asking - [x] I searched the [issues](https://github.com/apache/seatunnel/issues) and found no similar issues. ### What happened + What you expected to happen When the active Zeta master is lost **while a checkpoint is in flight** (its barrier has been dispatched, but not every task has acknowledged it), the surviving master publishes the next checkpoint with the **same checkpoint id** that the dead master had already allocated for the interrupted checkpoint. Checkpoint ids are allocated by incrementing the per-pipeline counter in the shared counter state store, and that increment is persisted at trigger time. On failover, `CheckpointManager` rebuilds each coordinator from the latest **completed** checkpoint and unconditionally rewinds the counter: ```java // CheckpointManager constructor, masterFailoverRestore path if (pipelineState != null) { long checkpointId = pipelineState.getCheckpointId(); idCounter.setCount(checkpointId + 1); // moves the counter backwards when a checkpoint was in flight ``` If checkpoint *N* was completed and checkpoint *N+1* was in flight when the master died, the counter store already held *N+2*, but the surviving master rewinds it to *N+1*. The next checkpoint is therefore allocated id *N+1* again. This is unsafe because `TaskAcknowledgeOperation` carries no trigger epoch: acknowledgements are matched to the pending checkpoint by id only (`CheckpointCoordinator#acknowledgeTask` looks the id up in `pendingCheckpoints`). A task that is still inside `snapshotState()` for the pre-failover barrier can therefore acknowledge the re-used id after the failover. The checkpoint that is then published can mix task state taken before the failover with task state taken after it, i.e. a torn checkpoint that may later be restored. Expected: checkpoint ids are strictly monotonic per pipeline across master failover. A checkpoint id that was already allocated (and possibly partially acknowledged) must never be issued again. ### Reproduction A deterministic E2E reproduction is straightforward on a 2-master + 1-worker cluster: 1. Streaming `FakeSource -> sink` job, `checkpoint.interval = 1000`, let the first checkpoint complete. 2. Make the sink writer park inside `snapshotState()`, so the second checkpoint's barrier reaches the tasks but cannot be acknowledged. 3. Shut down the active master, wait for the surviving master to take the job over, then release the sink. 4. Observe the checkpoint stored after the failover. On current `dev` the stored checkpoint after failover is `2` while checkpoint `2` was the interrupted one, and the same assertion fails with: ``` checkpoint 2 was already allocated and partially acknowledged before the failover, but the next stored checkpoint is 2 ==> expected: <true> but was: <false> ``` I will attach the E2E as a PR together with the fix. ### Anything else `CheckpointManagerTest#testMasterFailoverRestoreShouldLoadLatestCheckpointOfOwnJob` only covers the case where no checkpoint was in flight (counter absent), so the rewind was never observed by a test. ### Are you willing to submit a PR? - [x] Yes, I am willing to submit a PR! ### Code of Conduct - [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
