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

   Yes. This change is a contribution to Apache SeaTunnel.
   
   ### Problem
   
   Zeta restores a failed pipeline **in place** from 
`latestCompletedCheckpoint` inside
   `SubPlan#stateProcess` and keeps the same job and the same 
`CheckpointCoordinator` afterwards. A
   stop-with-savepoint request that arrives after that restore therefore has to 
capture the state of
   the **restored** attempt: its checkpoint id has to continue above the 
restore point, its writer
   state has to be the row counter the restored writer currently holds, and the 
resulting savepoint
   has to be accepted by `RestoreMode.SAVEPOINT` as a recovery point.
   
   This is the last unguarded step of the restore -> checkpoint -> savepoint -> 
restore chain. The
   savepoint is the only recovery artifact an operator can keep, and it is 
produced by the same
   coordinator that just went through a reset. If the reset leaves the 
coordinator pointing at the
   pre-failure checkpoint, or rewinds the id counter, the savepoint either 
reuses an id at or below the
   restore point (the restored job later resumes from rows it has already 
written) or publishes the
   pre-failure writer state instead of the current one (silent row loss on the 
next restore). Both
   outcomes look healthy: the savepoint request returns, the job reaches 
`SAVEPOINT_DONE`, and only
   the next restore exposes the lost rows. Neither symptom is observable 
without a real cluster, real
   checkpoint storage and a real restore.
   
   ### What this test adds
   
   `SavepointAfterPipelineRestoreIT` runs one STREAMING `FakeSource -> probe 
sink` pipeline on an in-JVM
   hybrid Zeta node (fixed slots, `dynamic-slot=false`, `slot-num=4`, 
`ScheduleStrategy.WAIT`,
   `checkpoint.interval=500`, `job.retry.times=3`). The test-only sink applies 
1 ms/row backpressure,
   publishes `WriterState(checkpointId, rows)` from `snapshotState`, reports 
every writer generation,
   and throws exactly once from `write()` after four snapshotted checkpoints. 
The contract is:
   
   1. the job-level status never leaves `RUNNING` while the pipeline fails and 
restores, and the
      pipeline is restored exactly once from a completed checkpoint whose 
writer state is non-empty
      and was snapshotted before the failure;
   2. the restored attempt checkpoints above both the restore point and the 
restored row counter
      (strictly more rows), so a savepoint that merely reuses the pre-failure 
state cannot pass the
      next assertions;
   3. a real client stop-with-savepoint completes, the job reaches 
`SAVEPOINT_DONE`, and the savepoint
      carries a checkpoint id strictly above the restore point with the row 
counter of the restored
      writer generation;
   4. `RestoreMode.SAVEPOINT` hands the new writer exactly that savepoint 
checkpoint id and row
      counter, the job reaches `RUNNING`, keeps consuming rows beyond the saved 
state and cancels
      cleanly to `CANCELED`.
   
   The failure is armed only after the pipeline has checkpointed, the savepoint 
is taken only after
   the restored attempt has checkpointed new rows, and every observation is a 
wait on a real state
   change published from the code under test, so the test is repeatable instead 
of timing-based.
   
   ### Existing coverage gap
   
   - `SavepointRestoreIT`, `SavepointClusterRestartRestoreIT`, 
`MultiPipelineSavepointRestoreIT` and
     `SavepointBusySourceBarrierIT` take savepoints from a job that never 
failed.
   - The in-place restore tests (`ClusterFaultToleranceTwoPipelineIT`, 
`SaturatedSlotPoolRestoreIT`,
     the restore-point guard, `CheckpointTimeoutRecoveryIT`) stop at "the 
restored pipeline keeps
     running"; none of them takes a savepoint from the restored attempt and 
then restores *that*
     savepoint.
   - `SavepointRestoreRetryIT` restores a savepoint twice, but never creates 
the savepoint after an
     in-place restore, so the restore -> savepoint handoff is untested.
   
   ### Modules and compatibility
   
   New test-tree files only, under
   `seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base`. No 
production code, public API,
   SPI, configuration option, default value, state or file format changes. The 
test-only sink is
   registered through `@AutoService` and is not visible outside the test 
classpath.
   
   ### Verification
   
   ```
   export JAVA_HOME=<jdk17>
   mvn -pl seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base 
spotless:apply
   mvn -pl seatunnel-engine/seatunnel-engine-server -DskipTests install
   mvn -pl seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base \
       verify -DskipUT=true -DskipIT=false 
-Dit.test=SavepointAfterPipelineRestoreIT -DfailIfNoTests=false
     Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 28.799 s
   mvn -pl seatunnel-ci-tools test -Dtest=ImportClassCheckTest
     Tests run: 8, Failures: 0, Errors: 0, Skipped: 0
   ```
   
   Three consecutive green targeted runs (~28.8 s each; the first green run of 
the final fixture was
   29.1 s). `spotless:check` is bound to `validate` and passed in every run. 
`git diff --check` is
   clean.
   
   Observed evidence from the final green run:
   
   ```
   Probe writer generation 1 ... opened from checkpoint -1 with 0 rows
   Probe writer generation 1 ... injecting the task failure after 8225 rows
   Probe writer generation 2 ... opened from checkpoint 4 with 8192 rows
   Job ... savepointed the restored attempt at checkpoint 8 with 16384 rows
   Probe writer generation 3 ... opened from checkpoint 8 with 16384 rows
   Job ... restored from the savepoint at checkpoint 8 with 16384 rows and kept 
consuming rows
   ```
   
   Negative control: temporarily dropping the restored task states in
   `CheckpointCoordinator#restoreTaskState` makes the test fail in 15.2 s with
   
   ```
   The restored writer must resume from a non-empty writer state:
   generation=2, restoredCheckpointId=-1, restoredRows=0
   ```
   
   The mutation was reverted, the pristine `seatunnel-engine-server` jar was 
reinstalled
   (sha256 `e3687ea6c3c4ebc9caffa94e8ad57c5d7dc5df90dcfa93ed219d91ce1339137a`) 
and the green run repeated.
   No engine defect was found: the savepoint-after-restore contract already 
holds on `dev`
   (`1e7e29a75b`), so no issue is filed with this change.
   
   ### Remaining risk
   
   The fixture uses `FakeSource` and the test-only probe sink purely as 
deterministic row generators
   and observers; it does not test connector, transform or SQL semantics. The 
savepoint restore is
   submitted with the same job id, matching the client `--restore` path.
   


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