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

   Yes — this change contributes to **Apache SeaTunnel** (Zeta engine E2E 
coverage).
   
   ### Motivation
   
   A Zeta checkpoint id is not free-standing metadata: checkpoint and savepoint 
artifacts are stored
   per job and pipeline and addressed by that id, so the id sequence of a live 
job id must never move
   backwards. The id is served by a per-pipeline counter 
(`StateStoreCheckpointIDCounter`, keyed by
   job id and pipeline id in the checkpoint counter state store). That counter 
is deliberately
   *removed* when the pipeline reaches a terminal state, and a 
stop-with-savepoint force-finishes the
   pipeline (`SubPlan#forcePipelineFinish`), so every savepoint stop discards 
the sequence. A restore
   therefore has to re-seed the counter from the restored checkpoint 
(`CheckpointManager` calls
   `setCount(restoredCheckpointId + 1)`).
   
   Dropping that re-seed is silent and only surfaces on the **second** restore 
cycle: the restored job
   still reaches `RUNNING`, still checkpoints and still commits data, but its 
checkpoint ids restart
   at 1, so the next savepoint reuses the id of the savepoint it was restored 
from, overwrites that
   artifact, and retention pruning can delete the wrong generation. A test that 
performs a single
   savepoint/restore cycle cannot see this, because the first restored id is 
the one seeded at
   submission.
   
   ### Change
   
   Test-only addition under 
`seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base`:
   
   - `RepeatedSavepointRestoreIT` starts one in-JVM master and one in-JVM 
worker and submits a single
     `CheckpointableSequenceSource -> LocalFile` pipeline (parallelism 1, 
finite range `[0, 20000)`,
     `checkpoint.interval=1000`). The local-file sink only moves a transaction 
into the output
     directory when the checkpoint completes, which turns the committed output 
into the exactly-once
     oracle.
   - After 1000 committed offsets, the job is stopped with a real savepoint and 
the published
     savepoint-type checkpoint is captured. The job is then restored from that 
savepoint and stopped
     with another savepoint, three cycles in total, before a final restore 
drains the remaining range.
   - Every stop must publish a `SAVEPOINT_TYPE` checkpoint, the savepoint ids 
must be strictly
     increasing across the cycles (the counter re-seed contract), each restored 
run must keep
     committing new offsets, and the final drain must reach `FINISHED` with 
exactly offsets
     `[0, 20000)`, no duplicate and no gap.
   
   No production code, public API, SPI, configuration option, default value, 
state or file format is
   touched.
   
   ### Existing coverage gap
   
   - `SavepointRestoreIT` performs exactly one savepoint/restore cycle.
   - `SavepointClusterRestartRestoreIT` restores once, after a cold cluster 
restart.
   - `SavepointRestoreRetryIT` re-submits the same restore but never takes a 
second savepoint from the
     restored job.
   - `ParallelSubtaskSavepointRestoreIT` restores with more than one subtask, 
but likewise stops after
     one restore.
   - None of them observes the id of a savepoint taken *after* a restore, so 
none can see the counter
     re-seed.
   
   I searched open and closed PRs/issues for `repeated savepoint`, `checkpoint 
id restore`,
   `savepoint restore counter` and `checkpoint counter` before opening this PR. 
The same-area results
   are the single-cycle tests above, the counter-leak fix #13483/#13482 (jobs 
that end before their
   pipelines start) and the master-failover monotonicity fix #13651 (in-flight 
id across a master
   switch); none of them covers repeated savepoint/restore cycles on one master.
   
   ### Verification
   
   ```bash
   export JAVA_HOME=<jdk17>
   mvn -o -pl seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base 
spotless:apply
   mvn -o -pl seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base \
       verify -DskipUT=true -DskipIT=false -Dit.test=RepeatedSavepointRestoreIT 
-DfailIfNoTests=false
     Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
   mvn -o -pl seatunnel-ci-tools test -Dtest=ImportClassCheckTest
     Tests run: 8, Failures: 0, Errors: 0, Skipped: 0
   git diff --check
   ```
   
   Five consecutive green runs on `dev` `1e7e29a75b` with the pristine 
`engine-server` jar
   (sha256 `e3687ea6c3c4ebc9caffa94e8ad57c5d7dc5df90dcfa93ed219d91ce1339137a`), 
35.5 s-36.1 s each.
   Observed savepoint sequence of a green run (the restored job is re-seeded 
from the savepoint it was
   restored from):
   
   ```
   Cycle 1 stopped at savepoint 3
   Cycle 2 stopped at savepoint 4
   Cycle 3 stopped at savepoint 5
   ```
   
   Negative control: removing the `idCounter.setCount(checkpointId + 1)` 
re-seed in
   `CheckpointManager` (mutation reverted, pristine jar reinstalled, same 
sha256) fails the new test in
   13.7 s with exactly the reuse this contract guards:
   
   ```
   Savepoint 2 of job ... must get a checkpoint id greater than the savepoint 
it was restored from
   (3), but got 3; the checkpoint id counter was not re-seeded from the 
restored state, so the new
   savepoint reused an existing checkpoint id and overwrote its artifact
   ==> expected: <true> but was: <false>
   ```
   
   ### Checklist
   
   - [x] Test-only change; no production behavior modified.
   - [x] No new dependencies; the fixture uses the existing checkpointable 
sequence source and the
     local-file sink.
   - [x] Deterministic waits only (no fixed sleeps for the contract assertions).
   - [x] Follows the repository formatting and import rules; 
`ImportClassCheckTest` passes.
   


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