You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "zhangshenghang (via GitHub)" <gi...@apache.org> on 2026/09/30 00:58:14 UTC

[I] [Bug][Zeta] Checkpoint state cleanup race lets late callbacks recreate cleaned checkpoint_state keys and live jobs never persist their status [seatunnel]

zhangshenghang opened a new issue, #12558:
URL: https://github.com/apache/seatunnel/issues/12558

   ### Description
   
   Since #10687 ("Guard state cleanup races after node failure"), `CheckpointCoordinator#updateStatus` skips persisting a coordinator status transition when the `checkpoint_state_<job>_<pipeline>` IMap key is absent, and `CoordinatorService` removes the job state keys without any coordination with that write. Two problems follow:
   
   1. **Late callbacks can recreate cleaned state (TOCTOU).** `updateStatus` does `get(checkpointStateImapKey)` and, if non-null, `set(...)` — with no lock. If the job state cleanup removes the key between the two calls, a late coordinator callback re-creates the `checkpoint_state_*` key after cleanup, leaving orphaned state in `runningJobStateIMap` that no one will ever remove. The cleanup also has no way to wait for or retry against a concurrent transition.
   
   2. **Live jobs never persist their coordinator status.** The first transition of a running pipeline (e.g. `reportedPipelineRunning -> restoreCoordinator -> updateStatus(RUNNING)`) now finds the key absent and skips, and since nothing else ever creates the key, **no transition is ever persisted for jobs that started fresh**. Consequences: on master switch / restore, the coordinator status is always missing (`checkpointCoordinatorStatus == null`), so coordinator restore cannot detect the previous status, and `isNoErrorCompleted()` (the "pipeline already finished without error, do not re-run" path) can never return true for these jobs.
   
   Expected:
   - The gate should be the owning job state (the job key in `runningJobStateIMap`), not the checkpoint state key itself: transitions are persisted only while the job is alive — a cleaned job has no job key anymore — while live jobs can still create their key on the first transition.
   - The check-and-write of `updateStatus` and the removal of the job key + `checkpoint_state_*` keys in the state cleanup should run under the same per-job lock of `runningJobStateIMap` (with a bounded wait), so a late callback can never recreate a key that cleanup already removed, and the cleanup retries later when the lock is unavailable.
   
   ### Impact
   
   Orphaned `checkpoint_state_*` IMap entries after job cleanup, and the coordinator-status based restore/no-error-completed optimizations silently stop working for jobs started after #10687.


-- 
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: commits-unsubscribe@seatunnel.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug][Zeta] Checkpoint state cleanup race lets late callbacks recreate cleaned checkpoint_state keys and live jobs never persist their status [seatunnel]

Posted by "SEZ9 (via GitHub)" <gi...@apache.org>.
SEZ9 commented on issue #12558:
URL: https://github.com/apache/seatunnel/issues/12558#issuecomment-5903493787

   Thanks for the detailed analysis. Could you confirm the SeaTunnel version/commit you observed this on, and whether you can reproduce the second symptom (checkpointCoordinatorStatus == null after master switch for a freshly started job) with a simple test or log snippet? That would help confirm the regression from #10687.
   
   The proposed fix sounds reasonable: gate persistence on the job key in runningJobStateIMap rather than the checkpoint_state key, and wrap both updateStatus's check-and-write and the cleanup's removal of job key + checkpoint_state_* keys in the same per-job IMap lock with a bounded tryLock. Would you be willing to open a PR? A unit test that races a late updateStatus callback against cleanup and asserts no orphaned checkpoint_state_* key would be very valuable.
   
   Note for reviewers: since #10687 was itself a race-guard fix, please double-check that gating on the job key still covers the original node-failure cleanup scenario (a cleaned job has no job key, so late callbacks should still be dropped), and that the bounded lock wait cannot stall cleanup indefinitely if a coordinator thread is stuck.
   
   <!-- streview-comment:1429 -->


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug][Zeta] Checkpoint state cleanup race lets late callbacks recreate cleaned checkpoint_state keys and live jobs never persist their status [seatunnel]

Posted by "CryoThrust (via GitHub)" <gi...@apache.org>.
CryoThrust commented on issue #12558:
URL: https://github.com/apache/seatunnel/issues/12558#issuecomment-5902375265

   I traced the current `dev` paths, and the missing first status write and the `get`/`set` cleanup race both look valid. Two boundaries seem worth pinning before implementing the per-job lock:
   
   1. `JobMaster#createJobCleanupRecord` explicitly includes the checkpoint and ready-to-close keys, but `CoordinatorService#createTerminalZombieCleanupRecord` snapshots only keys currently in the IMap. In the terminal-zombie path, a status key created after that snapshot but before cleanup would not be in `record.getStateKeys()`. If that path shares the lock, the key enumeration needs to be inside the same critical section as removal (or the known coordinator keys need explicit removal).
   2. Savepoint-start resubmission can reuse the same job ID and pipeline IDs: `cleanupPendingJobStateForRestore` removes the old keys, then a new `JobMaster` initializes. A late callback from the *old* coordinator could acquire the lock after the new job key exists and write its old status to the new round's `checkpoint_state_<job>_<pipeline>` key. Checking only that `runningJobStateIMap.get(jobId)` is non-null serializes the write but does not identify the execution round. Could the update be guarded by an owner/generation token (for example the initialization timestamp), with a test for an old callback arriving after same-ID resubmission?
   
   Adjacent path to consider: `updateReadyToCloseStartingTask` also writes a cleanup-owned key via `compute` without a job-liveness gate. It may need the same invariant, even if handled in a follow-up PR.
   


-- 
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: commits-unsubscribe@seatunnel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org