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

   ### 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
   
   **What happened.** Cancelling a job that was restored from a savepoint 
deletes that savepoint from checkpoint storage.
   
   A savepoint restore keeps the source job id (`JobMaster`/`CheckpointManager` 
restore path), so the restored run writes its periodic checkpoints into the 
same `<checkpoint-namespace>/<job-id>/` directory that holds the savepoint. 
When the restored run later reaches `CANCELED` (or `FINISHED`), the automatic 
cleanup calls `CheckpointStorage#deleteCheckpoint(String jobId)`, which removes 
the **whole job directory**:
   
   - `CheckpointManager#clearCheckpointIfNeed` 
(`seatunnel-engine-server/.../checkpoint/CheckpointManager.java:347`)
   - `CoordinatorService#cleanupTerminalZombieCheckpointIfNecessary` 
(`seatunnel-engine-server/.../CoordinatorService.java:1982`)
   
   Neither path distinguishes `SAVEPOINT_TYPE` entries from `CHECKPOINT_TYPE` 
entries, because `PipelineState` carries no checkpoint type; the type is only 
inside the serialized `CompletedCheckpoint`.
   
   Reproduction on current `dev` (`c0c6d04ca5`, `3.1.1-SNAPSHOT`), single 
in-process Zeta cluster, one pipeline, `checkpoint.interval = 2000`:
   
   1. Submit a streaming job, wait for a periodic checkpoint.
   2. `savePointJob(jobId)` -> job `SAVEPOINT_DONE`, savepoint id `2` stored 
(`getCheckpointData(jobId, SAVEPOINT)` returns it).
   3. Restore that savepoint (`restoreExecutionContext(..., jobId)`); the 
restored run keeps job id `1178328363845025793` and checkpoints again (id `3`).
   4. `cancelJob(jobId)` -> job `CANCELED`, cleanup runs.
   5. `jobClient.getCheckpointData(jobId, RestoreMode.SAVEPOINT)` now returns 
`[]`; the savepoint directory is gone.
   
   **What I expected.** A savepoint is operator-managed state and must survive 
automatic job cleanup. `docs/en/engines/zeta/state-storage-and-recovery.md` 
documents this explicitly:
   
   - Savepoint retention: "Kept until manually deleted"; lifecycle: "Managed by 
operator".
   - "A savepoint can be deleted only if you are certain you will never restore 
that job from it."
   
   So after step 4 the savepoint (id `2`) should still be present and 
restorable, and only the periodic checkpoint data of the cancelled run should 
be removed.
   
   **Why it matters.** The job itself looks healthy: the restored run reports 
`RUNNING`, checkpoints complete, and the cancel is clean. The loss is silent 
and only surfaces on the next restore, which then either fails with missing 
state or (before #13439/#13440 is fixed) silently starts a fresh job, i.e. 
duplicate or lost data. The failure mode is worse for the common "savepoint -> 
upgrade -> restore -> later cancel" flow, where the savepoint is the only 
rollback point.
   
   ### Reproduction
   
   The scenario is exercised by a new E2E test 
(`SavepointSurvivesRestoredJobCancelIT`) against a real in-process Zeta 
cluster; it fails on `dev` with:
   
   ```
   Cancelling the run restored from savepoint 2 of job 1178328363845025793 must 
not delete the savepoint.
   Savepoints left for job 1178328363845025793: []
   ```
   
   ### Anything else
   
   **Proposed fix.** Make the automatic cleanup savepoint-aware: list the job's 
stored checkpoints, deserialize the checkpoint type, keep `SAVEPOINT_TYPE` 
entries and delete only the remaining periodic entries (per pipeline). If the 
stored entries cannot be classified, keep everything rather than risk deleting 
a savepoint. Apply it to both cleanup paths above.
   
   **Related but distinct:** #11961 asks for a separate savepoint storage root 
/ format versioning. This issue is about the cleanup path destroying savepoints 
even with today's shared layout, so it needs a fix independently of #11961.
   
   ### Are you willing to submit a PR?
   
   - [x] Yes I am willing to submit a 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to