zhangshenghang opened a new pull request, #13784:
URL: https://github.com/apache/seatunnel/pull/13784

   Yes, I am contributing this change to Apache SeaTunnel under the project's 
contribution conventions.
   
   ## What this PR adds
   
   A test-only E2E guard for the Zeta engine contract around a 
**stop-with-savepoint that is still in flight when the active master is lost**. 
No production code is changed.
   
   `InterruptedSavepointFailoverIT` runs a streaming `FakeSource -> InMemory` 
job on a split cluster with **two master-only nodes and one dedicated worker**, 
waits for a periodic checkpoint, then requests a savepoint through the active 
master's `CoordinatorService#savePoint` — the exact server-side entry point of 
the client's savepoint operation. As soon as the job is `DOING_SAVEPOINT`, the 
per-pipeline checkpoint id counter has moved past the last completed checkpoint 
and the savepoint request has not completed, the active master is shut down.
   
   The contract asserted on the surviving master:
   
   1. the job leaves `DOING_SAVEPOINT` and returns to `RUNNING` instead of 
staying stuck in the interrupted savepoint state;
   2. the interrupted savepoint is **not published**: `getCheckpointData(jobId, 
RestoreMode.SAVEPOINT)` stays empty, so a later restore cannot pick up a torn 
recovery point;
   3. periodic checkpointing resumes, and the next completed checkpoint id is 
newer than the last checkpoint completed before the switch;
   4. the recovered job stays operable: it can still be cancelled to 
`CANCELED`, and the interrupted savepoint still does not surface.
   
   The client request itself is deliberately not used to trigger the savepoint: 
when its target member disappears Hazelcast may complete the invocation 
exceptionally at an arbitrary point, which would make the test race the 
client's transport rather than the engine's failover handling. Job submission, 
checkpoint observation, savepoint data and cancellation all go through the real 
`SeaTunnelClient`.
   
   ## Why existing coverage misses it
   
   - `SavepointRestoreIT`, `SavepointClusterRestartRestoreIT`, 
`MultiPipelineSavepointRestoreIT`, `SavepointBusySourceBarrierIT` and 
`SavepointRestoreRetryIT` only ever observe a savepoint that runs to completion 
on a healthy master.
   - `SavepointPreconditionRecoveryIT` covers a savepoint rejected before it 
starts (`TASK_NOT_ALL_READY_WHEN_SAVEPOINT`), not one interrupted after its 
checkpoint id was allocated.
   - `CheckpointCoordinatorFailoverIT` switches masters around checkpoints and 
the close handshake, but never while the job is `DOING_SAVEPOINT`; 
`SplitClusterPendingJobLifecycleFailoverIT` covers the pending queue.
   - The unit-level `SavePointBusySourceTest` stays inside one in-process 
server and never switches masters, so the persisted `DOING_SAVEPOINT` status is 
never handed to a new master.
   
   The boundary is reachable in production: `DOING_SAVEPOINT` is written to 
`runningJobStateIMap` before the savepoint barriers are injected, so a master 
loss during that window leaves the surviving master with a non-terminal job 
whose savepoint-in-progress bookkeeping died with the previous coordinator.
   
   ## Fixtures
   
   The job config (`stream_fake_to_slow_inmemory_savepoint_failover.conf`) 
keeps the source and sink as plain fixtures: a fast unbounded `FakeSource` and 
the existing test `InMemory` sink with `write_delay_ms = 1` and 
`checkpoint_sleep = true`. Together they keep the savepoint barrier in flight 
for several seconds (bounded intermediate queue plus a 5 s hold in 
`prepareCommit`), which makes the kill window deterministic instead of a race. 
No transform, SQL, connector or format behaviour is involved.
   
   ## Verification
   
   Command:
   
   ```
   ./mvnw -o -pl 
seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base verify \
     -DskipUT=true -DskipIT=false -Dit.test=InterruptedSavepointFailoverIT 
-DfailIfNoTests=false
   ```
   
   Green on `origin/dev` (`76889c9671`):
   
   - run 1: 58.4 s
   - run 2: 62.7 s
   - run 3: green
   
   Observed at the moment the master was killed: job status `DOING_SAVEPOINT`, 
last completed checkpoint id `1`, per-pipeline checkpoint counter `3` (the 
savepoint checkpoint id had been allocated), savepoint request future not done. 
After the switch: job status `RUNNING`, `storedSavepoints=[]`, next completed 
checkpoint of type `CHECKPOINT_TYPE`, then `CANCELED` after `cancelJob`.
   
   `spotless:check` is clean.
   


-- 
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