zhangshenghang opened a new issue, #13467:
URL: https://github.com/apache/seatunnel/issues/13467
## Search before asking
- [x] Searched existing issues and pull requests; no existing report
describes this exact failure mode. apache/seatunnel#10834 and
apache/seatunnel#12134 cover a **master** failover during a savepoint; this
report is about losing a **worker** while the savepoint is still in flight and
the master survives.
## What happened
A stop-with-savepoint request (`SeaTunnelClient#savePointJob`) against a
STREAMING job returns a failure after a worker that hosts the parked savepoint
barrier exits, but the job never leaves `DOING_SAVEPOINT`. It stays in that
state indefinitely (observed for more than 5 minutes, with no further pipeline
activity) even though the master and a second worker are healthy and can
schedule new jobs.
The stop path is entered correctly. The master logs:
```
PhysicalPlan - Job ... savepoint failed, stop all pipelines with checkpoint
fallback
```
and the pipeline simultaneously logs:
```
SubPlan - Task TaskGroupLocation{...} Failed ... Begin to cancel other tasks
in this pipeline.
```
The two actions race:
1. The lost worker fails the pipeline, so `SubPlan#stateProcess()` enters
`prepareRestorePipeline()`. That method increments the restore counter, resets
the pipeline to `CREATED`, and sleeps `job.retry.interval.seconds`.
2. The aborted savepoint makes `JobMaster#savePoint()` fail, so
`PhysicalPlan#savepointFailed()` calls `stopJob()`. Because the job is still
`DOING_SAVEPOINT`, `stopJob()` calls
`SubPlan#stopPipelineWithCheckpointFallback()` for every pipeline. That path
calls `forceStopPipeline()`, which calls `JobMaster#neverNeedRestore()`
(`needRestore = false`) and force-stops the vertices.
3. `prepareRestorePipeline()` wakes up from its sleep and returns `true`
unconditionally. `stateProcess()` then releases/re-applies resources and calls
`restorePipeline()`, so the pipeline is redeployed **behind the stop**.
4. `PhysicalPlan#stopJob()` does not update the job state in the
`DOING_SAVEPOINT` branch (it relies on the pipeline end callback to resolve it
to `SAVEPOINT_DONE`/`CANCELED`). Because the pipeline restored instead of
ending, no pipeline end callback ever decides the job state, and the job stays
`DOING_SAVEPOINT` forever.
## Expected behavior
A stop-with-savepoint is a stop command. If its final checkpoint cannot
complete, the job must still reach a terminal state (`FAILED` or `CANCELED`)
and release its resources; it must not stay in `DOING_SAVEPOINT` or continue as
`RUNNING` with a savepoint that never completed.
## Reproduction
The scenario is reproducible with an in-JVM Zeta cluster: one master member
plus two worker members, a STREAMING FakeSource job with `checkpoint.interval =
600000` and a test sink whose `snapshotState()` parks until released. Steps:
1. Start the job, take one savepoint, and restore the job from it so a
recovery point exists.
2. Request a second savepoint and wait until the master reports the held
checkpoint as an in-progress `SAVEPOINT_TYPE` checkpoint.
3. Shut down exactly the worker that owns the parked sink task; the second
worker stays alive so the pipeline can really restore.
4. Release the parked snapshot.
Observed on `dev` (before the fix): the savepoint request fails as expected,
but the job status stays `DOING_SAVEPOINT` for the whole 5-minute assertion
window.
Relevant state:
```
job status: DOING_SAVEPOINT
pipeline restore count: 1
savepoint request: failed with CheckpointException "Pipeline turn to end
state."
```
The same race is visible in the source: `SubPlan#prepareRestorePipeline()`
(`seatunnel-engine/seatunnel-engine-server/.../dag/physical/SubPlan.java`)
returns `true` after the sleep without consulting the `needRestore` flag that
`forceStopPipeline()` just cleared.
## Suggested fix
After the restore interval, re-check `jobMaster.isNeedRestore()` and return
`false` when a stop/cancel was requested while the pipeline was waiting, so the
pipeline follows the normal `subPlanDone()` path and the job resolves to a
terminal state. A focused PR with an E2E regression test will follow.
## SeaTunnel Version
`dev` at `e674d18b81` (3.1.1-SNAPSHOT).
## Java or Scala Version
JDK 17.
## Are you willing to submit PR?
- [x] Yes
## Code of Conduct
- [x] I agree to follow this project's Code of Conduct
Classification: A / Zeta savepoint lifecycle.
--
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]