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

   Yes, I am contributing to Apache SeaTunnel. This change only adds regression 
coverage to the Zeta engine E2E suite; no production code is modified.
   
   ### Purpose of this pull request
   
   Adds 
`CheckpointTimeoutPipelineRestoreIT#testPipelineRestoresFromLastCompletedCheckpointAfterTimeout`,
 an end-to-end test for what a `STREAMING` Zeta job does when one of its 
checkpoint barriers is not acknowledged before `checkpoint.timeout`.
   
   Contract under test:
   
   1. Three periodic checkpoints complete before the sink starts holding 
barriers, so a real recovery point exists.
   2. The sink parks inside `snapshotState` for one specific checkpoint. While 
it is still parked, the master must report that exact checkpoint as failed with 
the `CHECKPOINT_EXPIRED` reason and remove it from `inProgress`; the job must 
stay `RUNNING`.
   3. After the sink is released, the pipeline must restore exactly once 
(`pipelineRestoreNum == 1`), the job must stay `RUNNING`, and the checkpoint 
overview must record a restored pipeline.
   4. A later periodic checkpoint must complete with an id greater than the 
aborted one, and the aborted id must never be recorded as `COMPLETED`, so 
checkpoint ids never go backwards and are never reused.
   5. The restored sink writer must be handed the state of the last completed 
checkpoint (checkpoint 3 in the run below), never the state of the aborted 
barrier (checkpoint 4).
   6. The restored pipeline keeps consuming rows, and the job still cancels 
cleanly to `CANCELED`.
   
   ### Why this boundary has real regression risk
   
   A checkpoint timeout is the only checkpoint failure that a healthy job 
reports without any task failing: the sink is simply slow to snapshot (a large 
2PC commit, an object-store upload, a lock held by the source). 
`CheckpointCoordinator` arms a timeout task for every pending checkpoint and, 
when it fires, routes `CHECKPOINT_EXPIRED` through `handleCoordinatorError`, 
which must abort only that checkpoint and let the pipeline restore from the 
last completed one.
   
   Every hop of that chain fails silently when it regresses:
   
   - a timeout that is not armed leaves the pipeline `RUNNING` with a barrier 
that can never complete, so checkpoints stop forever with no error anywhere;
   - a timeout that still completes the aborted checkpoint poisons recovery 
with state that was never taken;
   - a restore that does not revive the coordinator leaves the restored 
pipeline running without checkpoints;
   - an id counter that is not advanced reuses the aborted id and makes the 
recovery point ambiguous again.
   
   None of those failures surfaces as a task error, so only an end-to-end 
assertion on the checkpoint lifecycle can catch them.
   
   ### Why existing coverage does not reach it
   
   - 
`CheckpointCoordinatorFailoverIT#testStreamJobFailsAfterCheckpointTriggerDispatchFailure`
 injects a barrier-dispatch failure and expects the job to `FAIL`.
   - `CheckpointRestoreWithStopIT` and `RecoveryLifecycleRestApiIT` recover 
from checkpoints that completed normally.
   - `RestApiIT#testCheckpointOverviewAndHistoryApi` fabricates a 
`CHECKPOINT_EXPIRED` entry by calling the monitor service directly; it never 
arms, expires, or restores anything.
   - `SavepointBusySourceBarrierIT` races a savepoint against a busy source but 
never lets a periodic checkpoint expire.
   - `ClusterFaultToleranceIT` / `SplitClusterFaultToleranceIT` cover worker 
and master failover, a different recovery entry point.
   
   ### How the test pins the window
   
   `CheckpointTimeoutHoldSink` consumes every row but parks the acknowledgement 
of one configurable snapshot on `CheckpointTimeoutHoldGate`, with 
`checkpoint.interval = 1000` and `checkpoint.timeout = 2000` in the job config. 
The gate swallows the interrupts raised by the pipeline cancellation, so the 
sink stays parked until the test has observed the timeout on the master. The 
test releases the gate only after the checkpoint overview reports the exact 
held checkpoint as failed with the `CHECKPOINT_EXPIRED` reason while the sink 
is still parked, which cleanly separates "the timeout fired" from "the sink 
finally acked". The sink checkpoints a state string that identifies the 
checkpoint it belongs to, so the recovery assertion verifies which checkpoint 
state was actually restored rather than only that the job restarted.
   
   `FakeSource` and the test sink are simple fixtures only; no Transform, SQL, 
connector or format behavior is exercised.
   
   ### Does this PR introduce _any_ user-facing change?
   
   No. This is test-only coverage; no engine behavior, configuration, or API is 
changed.
   
   ### How was this patch tested?
   
   ```bash
   JAVA_HOME=/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home \
   ./mvnw -o -pl 
seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base \
     -DskipUT=true -DskipIT=false \
     -Dtest=CheckpointTimeoutPipelineRestoreIT -DfailIfNoTests=false verify
   ```
   
   (actual invocation used `-Dit.test=CheckpointTimeoutPipelineRestoreIT`)
   
   - New test on this branch: `Tests run: 1, Failures: 0, Errors: 0`, ~19s.
   - Executed three times locally with the same result.
   - `spotless:check` passes for the module.
   - The run log shows the expected sequence: checkpoint 4 expires while the 
sink is held, the pipeline is cancelled and restored, the sink state is 
restored from checkpoint 3, new checkpoints complete past id 4, and the job 
cancels cleanly.
   - No production code changed, so no unit test is affected.
   
   ### Check list
   
   * [ ] If any new Jar binary package adding in your PR, please add License 
Notice according
     [New License 
Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/developer/new-license.md)
   * [ ] If necessary, please update the documentation to describe the new 
feature. https://github.com/apache/seatunnel/tree/dev/docs
   * [ ] If necessary, please update `incompatible-changes.md` to describe the 
incompatibility caused by this PR.
   * [ ] If you are contributing the connector code, please check that the 
following files are updated:
     1. Update 
[plugin-mapping.properties](https://github.com/apache/seatunnel/blob/dev/plugin-mapping.properties)
 and add new connector information in it
     2. Update the pom file of 
[seatunnel-dist](https://github.com/apache/seatunnel/blob/dev/seatunnel-dist/pom.xml)
     3. Add ci label in 
[label-scope-conf](https://github.com/apache/seatunnel/blob/dev/.github/workflows/labeler/label-scope-conf.yml)
   


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