DanielLeens opened a new issue, #13481: URL: https://github.com/apache/seatunnel/issues/13481
### Search before asking - [x] I had searched in the [issues](https://github.com/apache/seatunnel/issues?q=is%3Aissue) and found no similar issues. ### What happened In a multi-pipeline Zeta job with checkpointing enabled (e.g., multiple independent source-to-sink pipelines in one job where a fast/bounded pipeline finishes earlier while another pipeline is still `RUNNING`), triggering a stop-with-savepoint (`savePoint(jobId)`) fails with `CheckpointException: CheckpointCoordinator shutdown.` even though the job itself is still `RUNNING`. Worse, because `CheckpointManager.triggerSavePoints()` / `triggerSavePointsAndWaitComplete()` fans out `startSavepoint()` to **all** coordinators in `coordinatorMap` in parallel—including pipelines whose `CheckpointCoordinator` has already cleanly finished—the remaining active pipeline(s) **still execute the savepoint and suspend**, while the already-finished pipeline immediately rejects `startSavepoint()` with `CHECKPOINT_COORDINATOR_SHUTDOWN`. On current `dev` (verified at commit `39c74ce48b0`), this causes a severe split-brain failure: 1. The finished pipeline returns a failed future (`CheckpointCloseReason.CHECKPOINT_COORDINATOR_SHUTDOWN`). 2. The still-running pipeline completes its savepoint and enters `CheckpointCoordinatorStatus.SUSPEND` (`anyPipelineSuspended = true`). 3. In `JobMaster.savePoint()`, because `savepointCompleted == false` and `anyPipelineSuspended == true`, `isSavepointStartPreconditionFailure(...)` returns `false`, so the `finally` block executes `physicalPlan.savepointFailed()` -> `stopJob()`, and `savePoint()` throws `SeaTunnelEngineException(CheckpointException: CheckpointCoordinator shutdown.)` to the caller. 4. In addition, `CheckpointManager.isSavePointEnd()` reduces `CheckpointCoordinator::isEndOfSavePoint` with logical AND (`&&`) across **all** pipelines in `coordinatorMap`. Because the finished pipeline completed with `COMPLETED_POINT_TYPE` rather than `SAVEPOINT_TYPE`, `isEndOfSavePoint()` is `false` for that pipeline, making `isSavePointEnd()` return `false` for the whole job—which can cause `clearCheckpointIfNeed()` to delete the job's checkpoint/savepoint data when the job ends in `CANCELED` or `FINISHED`. ### Root Cause Analysis (Source Code on `dev` `39c74ce48b0`) 1. **`CheckpointManager.triggerSavePoints()` and `triggerSavePointsAndWaitComplete()` do not skip already-completed pipelines** - File: `seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/checkpoint/CheckpointManager.java` (lines 251–267) ```java public PassiveCompletableFuture<CompletedCheckpoint>[] triggerSavePoints() { return MDCTracer.tracing(coordinatorMap.values().parallelStream()) .map(CheckpointCoordinator::startSavepoint) .toArray(PassiveCompletableFuture[]::new); } public PassiveCompletableFuture<CheckpointCoordinatorState>[] triggerSavePointsAndWaitComplete() { return MDCTracer.tracing(coordinatorMap.values().parallelStream()) .map(CheckpointCoordinator::startSavepointAndWaitComplete) .toArray(PassiveCompletableFuture[]::new); } ``` `coordinatorMap` retains coordinators for all pipelines of the job until job completion. Unlike `acknowledgeTask()` or `triggerSchemaChangeBeforeCheckpoint()`, which check `if (coordinator.isCompleted()) return;`, `triggerSavePoints*()` invokes `startSavepoint()` on already-finished pipelines too. 2. **`CheckpointCoordinator.startSavepoint()` unconditionally errors when `shutdown || isCompleted()`** - File: `seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/checkpoint/CheckpointCoordinator.java` (lines 936–941) ```java if (shutdown || isCompleted()) { return completableFutureWithError( CheckpointCloseReason.CHECKPOINT_COORDINATOR_SHUTDOWN); } ``` A pipeline that legitimately reached `FINISHED` already has `isCompleted() == true` and `isNoErrorCompleted() == true`. 3. **`JobMaster.savePoint()` treats partial suspension + finished-pipeline shutdown error as a fatal savepoint failure** - File: `seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/master/JobMaster.java` (lines 1395–1438, 1480–1533) - Pipeline 1 (already `FINISHED`) fails with `CHECKPOINT_COORDINATOR_SHUTDOWN`. - Pipeline 2 (still `RUNNING`) suspends with `SUSPEND` (`anyPipelineSuspended == true`). - `isSavepointStartPreconditionFailure()` returns `false` because `anyPipelineSuspended` is `true`, so `finally` runs `physicalPlan.savepointFailed()` and the RPC throws `SeaTunnelEngineException`. 4. **`CheckpointManager.isSavePointEnd()` requires every pipeline to end with `SAVEPOINT_TYPE`** - File: `seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/checkpoint/CheckpointManager.java` (lines 424–429) ```java public boolean isSavePointEnd() { return coordinatorMap.values().stream() .map(CheckpointCoordinator::isEndOfSavePoint) .reduce((v1, v2) -> v1 && v2) .orElse(false); } ``` When Pipeline 1 ended with `COMPLETED_POINT_TYPE` and Pipeline 2 ended with `SAVEPOINT_TYPE`, `isSavePointEnd()` evaluates to `false`. ### SeaTunnel Version `dev` (commit `39c74ce48b0`) ### Minimal Reproduction Steps 1. Start a SeaTunnel Zeta cluster (single-node or multi-node) with local/distributed checkpoint storage enabled. 2. Submit a two-pipeline job with checkpointing enabled where Pipeline 1 finishes quickly and Pipeline 2 stays running: ```hocon env { job.mode = "BATCH" parallelism = 1 checkpoint.interval = 1000 } source { FakeSource { result_table_name = "fast_rows" row.num = 3 schema { fields { id = "int" } } } FakeSource { result_table_name = "slow_rows" row.num = 2 split.num = 2 split.read-interval = 600000 schema { fields { id = "int" } } } } sink { Console { source_table_name = ["fast_rows"] } Console { source_table_name = ["slow_rows"] } } ``` 3. Wait until: - Pipeline 1 reaches `PipelineStatus.FINISHED` (`coordinator1.isCompleted() == true`, `isNoErrorCompleted() == true`). - Pipeline 2 is still `PipelineStatus.RUNNING` and has completed at least one periodic checkpoint. - Overall `JobStatus` is still `RUNNING`. 4. Trigger savepoint on the job via CLI (`./bin/seatunnel.sh -s <jobId>`) or `SeaTunnelClient.savePointJob(jobId)`. ### Expected Behavior - Savepoint should skip pipelines that have already cleanly completed (`isNoErrorCompleted() == true`) and only trigger savepoint on active/incomplete pipelines. - `savePointJob(jobId)` should succeed without throwing `CHECKPOINT_COORDINATOR_SHUTDOWN`. - `CheckpointManager.isSavePointEnd()` should return `true` when at least one pipeline ended with savepoint and all other pipelines ended with either savepoint or clean completion (`isNoErrorCompleted()`). - Restoring the job from that savepoint should skip the already-completed Pipeline 1 (via `CheckpointManager.isCompletedPipeline(pipelineId)`) and resume Pipeline 2 cleanly. ### Actual Behavior - `savePointJob(jobId)` fails and throws: ```text org.apache.seatunnel.engine.common.exception.SeaTunnelEngineException: java.util.concurrent.ExecutionException: org.apache.seatunnel.engine.server.checkpoint.CheckpointException: CheckpointCoordinator shutdown. ``` - Meanwhile, Pipeline 2 still executes its savepoint and stops/suspends, `CheckpointManager.isSavePointEnd()` returns `false`, and on `dev` `JobMaster.savePoint()` enters `physicalPlan.savepointFailed()` because `anyPipelineSuspended == true`. ### Suggested Fix Direction 1. In `CheckpointManager.triggerSavePoints()` and `triggerSavePointsAndWaitComplete()`, skip coordinators that are already cleanly completed (`isNoErrorCompleted()`), or return an already-completed state for them while triggering savepoint on active pipelines. Ensure `JobMaster.waitSavepointCompleted()` accepts cleanly `FINISHED` pipelines alongside `SUSPEND` pipelines (while still failing if any pipeline failed/canceled or if no active pipeline could savepoint). 2. In `CheckpointManager.isSavePointEnd()`, return `true` when at least one pipeline has `isEndOfSavePoint() == true` and all remaining pipelines satisfy `isEndOfSavePoint() || isNoErrorCompleted()`. 3. Add a Zeta E2E test covering a two-pipeline job where Pipeline 1 finishes first, Pipeline 2 is savepointed while running, `savePointJob` succeeds, and restoring from savepoint skips Pipeline 1 and finishes Pipeline 2. ### Call for Contributors This is a well-scoped, deterministic Zeta engine bug with clear reproduction steps and a straightforward fix surface (`CheckpointManager`, `JobMaster`, and Zeta E2E tests). **Contributors are very welcome to claim this issue and open a PR!** If you'd like to work on it, please leave a comment below to claim it. -- 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]
