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

   Yes, I am contributing to Apache SeaTunnel. This change adds Zeta engine E2E 
coverage only; no production code is modified.
   
   ### What this adds
   
   `CheckpointSingleFlightIT` pins the checkpoint scheduler's single-flight 
contract when one checkpoint outlives several trigger intervals, using a 
test-only sink that parks inside the first `SinkWriter#snapshotState` call 
(checkpoint timeout is 30s, so the barrier is genuinely pending, not expiring).
   
   Contract under test, on one in-process hybrid Zeta node with 
`dynamic-slot=false`, `slot-num=4`, `checkpoint.interval=500ms`, 
`checkpoint.timeout=30000`, `job.retry.times=0`:
   
   1. While the first checkpoint is provably in flight (the sink is parked and 
the overview lists that exact id as in progress), periodic triggers must be 
skipped and re-armed rather than turned into a second pending checkpoint: for 
several intervals the overview keeps `triggered == 1`, `inProgress == 1` for 
the held id, `completed == 0`, `failed == 0`, `restored == 0`, no 
`latestCompleted`/`latestFailed`, and the sink sees exactly one snapshot 
request.
   2. A skipped trigger is not a checkpoint failure: the job stays `RUNNING` 
with `job.retry.times=0`, so a spurious failure would be terminal.
   3. After the release, the held checkpoint completes exactly once (one 
`COMPLETED` history entry for that id) and the chain is still alive: a later 
checkpoint with a strictly greater id completes, no checkpoint fails, and no 
pipeline restore happens.
   4. Snapshot requests are unique and strictly increasing, i.e. two 
checkpoints are never snapshotted at the same time.
   5. Cancelling reaches `CANCELED`, the scheduler stops (no snapshot request 
after the terminal drain), and the pipeline's fixed slot ownership is released.
   
   ### Why this boundary has real regression risk
   
   The whole single-flight decision is one `pendingCounter > 0` branch in 
`CheckpointCoordinator#tryTriggerPendingCheckpoint`. If it regresses, two 
barriers are injected into the same pipeline and two snapshots run 
concurrently, doubling snapshot load and allowing a checkpoint to be completed 
from a mix of two states. If the skipped trigger is not re-armed, checkpointing 
stops forever with no task error and no failed job. Neither failure changes the 
job status, so only the checkpoint overview plus a sink-side record of the 
actual snapshot requests can expose it.
   
   ### Why existing coverage does not reach it
   
   - `CheckpointEnableIT` only checks savepoint/restore and interval plumbing.
   - `CheckpointCoordinatorFailoverIT` switches the master between checkpoints; 
it never holds one checkpoint across several trigger periods.
   - `SinkAggregatedCommitterTaskCheckpointCacheLeakIT` runs many real 
checkpoints, but its sink answers every snapshot immediately, so the 
pending-checkpoint window is never wider than one trigger period.
   - `CheckpointRestoreWithStopIT` / `SavepointRestoreIT` restore completed 
checkpoints; they do not observe scheduling while a checkpoint is pending.
   
   ### How the window is pinned
   
   `CheckpointSingleFlightSink` records each snapshot request id in call order 
and parks the first one on a gate. The test only starts its hold-window 
assertions after that gate is entered, and only releases it after sampling the 
overview across several intervals, so "the checkpoint is still in flight" is 
established by the sink and the master overview, not by a sleep. The job config 
uses `FakeSource -> test sink` as a simple fixture; no Transform, SQL, 
connector or format behaviour is exercised.
   
   ### Verification
   
   Nine consecutive green runs of the only test in the class on `origin/dev` 
`5cf050be3f`, JDK 17 (`mvnw ... verify -Dit.test=CheckpointSingleFlightIT`), 
8.6s-10.1s each, including `spotless:check`; the last runs were after the final 
Javadoc-only edit.
   
   Negative control: removing the `pendingCounter > 0` single-flight guard from 
`CheckpointCoordinator#tryTriggerPendingCheckpoint` (test-only probe) makes the 
test fail in 6.3s at the first hold-window assertion with:
   
   ```
   AssertionFailedError: exactly one checkpoint must have been created while 
the first was held,
   counts=CheckpointCounts(triggered=2, completed=0, failed=0, inProgress=2, 
restored=0)
   expected: <1> but was: <2>
   ```
   
   The probe was reverted, the pristine `seatunnel-engine-server` jar was 
reinstalled (SHA-256 
`97dd3e224d0e08a6317132c93e274fcbc61db56ea59c3fdb5ab150bec06dd312`), and green 
runs were repeated on the pristine build.
   
   No GitHub issue is filed because this PR adds coverage for behaviour that is 
currently correct; no production code is touched.
   


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