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

   ### Contribution acknowledgement
   
   Yes — I am contributing this change to **Apache SeaTunnel**, and I confirm 
it follows the project's contribution conventions (English PR 
title/description, one focused change, formatting and tests validated locally).
   
   ### What this changes
   
   `CheckpointCoordinator#completePendingCheckpoint` maintained its 
per-pipeline retention queue by appending the checkpoint id **before** the 
storage write. That queue is the engine's only record of which checkpoint ids 
are durable: every retention cycle, the oldest entries are handed to 
`CheckpointStorage#deleteCheckpoint(jobId, pipelineId, ids)`. If 
`storeCheckPoint` throws (storage outage, revoked credential, full disk), the 
already-appended id survived the failure, so:
   
   - a later retention request asked storage to delete a checkpoint id that was 
never written (`LocalFileStorage` only logs this), and
   - the queue no longer described the files that exist, i.e. the retention 
bound the operator configured stopped being meaningful.
   
   This PR records the id only after the store returned successfully. 
Checkpoint types that are deliberately not stored keep the previous behaviour 
(they are still recorded after the skipped store).
   
   This addresses the "records ids before storage succeeds" half of #13322. The 
other half of that issue — ids surviving a pipeline restore — is intentionally 
unchanged: those queue entries correspond to checkpoint files that really 
exist, so keeping them is what lets retention delete the right block after a 
restore; clearing the queue there would leak files rather than remove drift.
   
   ### New E2E
   
   `CheckpointRetentionLedgerIT` (engine E2E module; single in-process hybrid 
Zeta node, fixed slots, one `FakeSource -> Console` STREAMING pipeline, 
`checkpoint.interval = 500`, `checkpoint.storage.max-retained = 2`) points the 
job's checkpoint storage at a test-only `LocalFileStorage` subclass that 
rejects exactly one `storeCheckPoint` and records every successful write and 
every retention delete request. The rejected write restores the pipeline, so 
the observed sequence crosses a generation boundary. The test requires that:
   
   1. every checkpoint id in every retention request was successfully persisted 
first;
   2. retention still works after the failure — at least two requests are made, 
no request deletes more than `max-retained` ids, requests are strictly 
oldest-first and no id is deleted twice;
   3. the requests agree with the backing store — a deleted id is not readable, 
every retained id is, and the job namespace never holds more than one in-flight 
block of extra files;
   4. the streaming job stays `RUNNING` across the restore and still cancels 
cleanly into `CANCELED` with its checkpoint data deleted.
   
   The exact pruning cadence is deliberately not pinned (deleting one id as 
soon as the bound is exceeded and deleting a full block at once are both valid 
policies), so this test composes with the open retention work in #12236 / 
#12678 instead of competing with it.
   
   No transform, SQL, connector or format behaviour is involved: 
`FakeSource`/`Console` are only fixtures for the engine's checkpoint scheduler 
and retention bookkeeping.
   
   ### Verification
   
   - `CheckpointRetentionLedgerIT`: green four consecutive runs with the final 
version (9.881s, 9.767s, 10.042s, 9.607s); every run reported `BUILD SUCCESS` 
with the module `spotless:check` enabled.
   - Negative control: replacing only `CheckpointCoordinator.java` with 
`origin/dev` (one-line move reverted) makes the same E2E fail in 8.994s at the 
first invariant with `retention asked storage to delete checkpoint 1 which was 
never successfully persisted; persisted=[2, 3, 4, 5, 6, 7, 8], rejected=[1], 
deleteRequests=[DeleteRequest{pipelineId=1, checkpointIds=[1, 2]}, ...]`; the 
fix was then re-applied and the green runs repeated.
   - `CheckpointCoordinatorTest` 19/19 and `CheckpointManagerTest` 9/9 green in 
`seatunnel-engine-server`.
   - `spotless:check` exit 0 for `seatunnel-engine-server` and 
`connector-seatunnel-e2e-base`.
   


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