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

   ### Purpose of this pull request
   
   Yes, I am contributing to Apache SeaTunnel.
   
   Fixes #13439.
   
   A checkpoint/savepoint restore submitted through the **client API** silently 
turned into a fresh execution when the referenced source job had no 
restore-eligible checkpoint data. 
`ClientJobExecutionEnvironment#getJobConfigParser()` loaded the checkpoint list 
from `JobClient#getCheckpointData`, and an empty result was passed to 
`MultipleTableJobConfigParser`, which then skipped the restore branch 
(`MultipleTableJobConfigParser` line 446) and built a brand-new source. The 
destination job was submitted and ran from offset zero while still looking 
`RUNNING`.
   
   This contradicts the documented contract 
(`docs/en/engines/zeta/rest-api-job-lifecycle.md`: "If the checkpoint data for 
`restoreSourceJobId` is missing, already cleaned up, or incompatible, the 
submission fails fast") and the behavior of the other two restore entry points, 
which already reject the request:
   
   * `RestJobExecutionEnvironment` throws `No checkpoint found for jobId=...` 
(pinned by `RestApiSubmitJobStartWithSavePointTest`, HTTP 400);
   * `ApplicationJobExecutionEnvironment` throws the same error.
   
   The client entry point behind `bin/seatunnel.sh --restore-with-checkpoint` 
and `bin/seatunnel.sh -r/--restore` was the only path missing the guard.
   
   ### Changes
   
   - **Fix:** `ClientJobExecutionEnvironment#getJobConfigParser()` now throws 
`IllegalArgumentException("No checkpoint found for jobId=..., restoreMode=..., 
restoreSourceJobId=...")` when a restore mode is requested and no checkpoint 
data is returned, before any job is created. Same message shape as the 
server-side entry points.
   - **Unit test:** 
`SeaTunnelClientTest#testRestoreWithoutCheckpointDataFailsFast` covers both 
`restoreFromCheckpointExecutionContext` (CHECKPOINT) and 
`restoreExecutionContext` (SAVEPOINT), and asserts the failure identifies the 
source job id.
   - **E2E regression test:** `ClientCheckpointRestoreMissingDataIT` runs a 
two-node embedded Zeta cluster and drives the real engine lifecycle: submit a 
streaming job with periodic checkpoints, wait for a completed checkpoint, 
cancel it with the default `checkpoint.retain-after-job-cancelled=false`, wait 
until its checkpoint data is actually deleted from storage, then attempt a 
client checkpoint restore into a new job id. It asserts the restore is 
rejected, no destination job is submitted, and no checkpoint data is created 
for the destination job.
   
   `FakeSource -> Console` is used only as a simple fixture to keep a 
checkpointable streaming pipeline alive; the assertions are about engine 
checkpoint retention, restore preconditions and job lifecycle, not connector 
behavior.
   
   Existing coverage did not reach this boundary: the REST and application 
guards are unit-tested, but no E2E restore test restores from a source whose 
checkpoint data was already cleaned up, and the client path had no guard at all.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, but only in the failure direction: a client restore that previously 
"succeeded" by silently replaying the job from scratch now fails fast with a 
clear error. Successful restores are unaffected (verified by the existing 
`testSavePointAndRestoreWithSavePoint` and the E2E savepoint tests). No 
configuration option, API or data format changes.
   
   ### How was this patch tested?
   
   ```bash
   # Client unit tests (existing savepoint restore + new fail-fast precondition)
   ./mvnw -pl seatunnel-engine/seatunnel-engine-client \
     
-Dtest='SeaTunnelClientTest#testSavePointAndRestoreWithSavePoint+testRestoreWithoutCheckpointDataFailsFast'
 \
     -DfailIfNoTests=false test
   # Tests run: 2, Failures: 0, Errors: 0, Skipped: 0 (8.4s)
   
   # E2E regression test
   ./mvnw -pl seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base \
     -DskipUT -DskipIT=false \
     -Dit.test=ClientCheckpointRestoreMissingDataIT \
     -DfailIfNoSpecifiedTests=false verify
   # Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 (~14s), executed twice
   ```
   
   Before the fix the same E2E test fails with:
   
   ```
   A checkpoint restore from canceled job 1177869475517562881 whose checkpoint 
data was already deleted must be rejected,
   but the client submitted destination job 1177869475517628417 
(status=CREATED) and would replay the job from offset zero
   ```
   
   `./mvnw -pl 
seatunnel-engine/seatunnel-engine-client,seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base
 spotless:check` 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