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

   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 
`DuplicateSavepointIT#testConcurrentSavepointRequestsShareOneSavepoint`, an 
end-to-end test for what a `STREAMING` Zeta job does when two savepoint 
requests arrive while the first savepoint is still in flight.
   
   Contract under test:
   
   1. A periodic checkpoint completes first, so the savepoint is a distinct, 
later checkpoint id.
   2. The test sink parks inside `SinkWriter#snapshotState` for the savepoint 
barrier, so the first savepoint operation is provably in flight and 
unacknowledged; the job is `DOING_SAVEPOINT` and the held checkpoint is 
registered as a `SAVEPOINT`.
   3. A second client savepoint request is issued from another thread while the 
first barrier is held. Both requests must be served by the same savepoint 
operation: neither settles before the barrier is released.
   4. After the barrier is released, both client requests must complete 
successfully (no spurious savepoint failure for a valid duplicate request), and 
the job must end exactly once, in `SAVEPOINT_DONE`.
   5. The checkpoint monitor must record exactly one `SAVEPOINT` entry - the 
held id - and no checkpoint after it; the sink must observe exactly the 
periodic checkpoint and the one savepoint (no second savepoint barrier, no 
periodic checkpoint behind the savepoint).
   6. The duplicate must not restart the pipeline: no pipeline restore, no 
failed checkpoint, no in-progress checkpoint left behind, and the job must stay 
`SAVEPOINT_DONE` over a stability window.
   
   ### Why this boundary has real regression risk
   
   A savepoint request is not guaranteed to arrive exactly once: an operator 
can double-click in the UI, a CLI wrapper can retry after a timeout, and two 
controllers can race. `CheckpointCoordinator#startSavepoint` keeps the 
in-flight savepoint in `savepointPendingCheckpoint` and returns its future to 
any request that arrives before it settles, so different savepoint requests 
share one savepoint operation. That coalescing is the only thing that keeps a 
duplicate from either:
   
   - failing after the first request has suspended the coordinator 
(`CheckpointCoordinator shutdown` for the duplicate) - a spurious client error 
for a perfectly valid request, or
   - creating a second final checkpoint on a pipeline that is already 
suspended, which either fails the job with a checkpoint error or leaves two 
savepoints for one run.
   
   Both outcomes are silent from the outside: the first savepoint still 
succeeds, so no task, job status or checkpoint metric reports the duplicate 
failure unless the duplicate's own client future is inspected.
   
   ### Why existing coverage does not reach it
   
   - `SavepointDuringInFlightCheckpointIT` (#13503) sends one savepoint while a 
*periodic* checkpoint is pending; it never sends a second savepoint.
   - `SavepointInFlightMasterFailoverIT` (#13486) checks that a savepoint is 
not retried after a master switch; the master disappears, so there is no 
concurrent duplicate.
   - `SavepointFirstCheckpointIT` (#13476), `SavepointPacingIT` (#13703) and 
`SavepointSurvivesRestoredJobCancelIT` (#13473) cover other savepoint 
scheduling boundaries.
   - No unit test exercises `startSavepoint`'s `savepointPendingCheckpoint` 
coalescing; the only reference in the repository is the field's own comment.
   
   ### How the test pins the window
   
   `SavepointDedupeSinkWriter` reaches `snapshotState` for the savepoint and 
parks on a static gate (same JVM as the in-process cluster) until the test 
releases it. The test first waits for a completed periodic checkpoint, arms the 
gate, requests the savepoint from one thread, waits until the gate reports that 
the savepoint snapshot is parked (and that the in-progress checkpoint type is 
`SAVEPOINT`), then requests the savepoint again from a second thread. It 
releases the gate only after proving both requests are still pending, then 
asserts on the client futures, the checkpoint monitor history/overview and the 
observed barrier ids. `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 \
     -Dit.test=DuplicateSavepointIT -DfailIfNoTests=false verify
   ```
   
   - New test on this branch: `Tests run: 1, Failures: 0, Errors: 0`, ~10.5s.
   - Executed four times locally with the same result (10.6s, 10.5s, 10.5s, 
10.5s after the final edits).
   - Negative control: with the `savepointPendingCheckpoint` coalescing removed 
from `CheckpointCoordinator#startSavepoint` (temporary engine change, reverted 
afterwards), the duplicate request fails with `CheckpointException: 
CheckpointCoordinator shutdown.` and the test fails at the second client 
future, confirming the guard is not vacuous.
   - `spotless:check` passes for the module.
   - `ImportClassCheckTest` passes.
   - `git diff --check` passes.
   
   ### 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