zhangshenghang opened a new pull request, #13721:
URL: https://github.com/apache/seatunnel/pull/13721
Yes, I am contributing to Apache SeaTunnel.
### Purpose of this pull request
Adds an E2E regression guard for the recovery point a Zeta master failover
selects after the **same savepoint has been restored more than once**.
A savepoint restore keeps the job id, so the restored run writes periodic
checkpoints into the same `<job-id>` directory as the savepoint, and its
checkpoint-id counter continues from `savepoint id + 1`. If that restored run
fails, its checkpoints stay on disk. Restoring the same savepoint again starts
a new attempt whose checkpoint ids **overlap** the superseded attempt's ids but
are written later. The store therefore holds two executions under one job id:
| write order | checkpoint ids | attempt |
|---|---|---|
| earlier | 3, 4, 5, 6, 7 | superseded restore attempt (failed) |
| later | 3 | current restore attempt |
The recovery point used after a master failover must be the **current
attempt's** newest checkpoint. Checkpoint ids are per attempt and are rewound
by a restore, so the highest id is not the newest recovery point:
`CheckpointStorage#getLatestCheckpointByJobIdAndPipelineId` resolves the latest
durable checkpoint by the write order encoded in the stored checkpoint file
name, not by the checkpoint id. A change that "simplifies" the lookup to
compare checkpoint ids (or a restore path that fails to supersede the previous
attempt) still leaves the job `RUNNING` and checkpointing, but resumes it from
a state that belongs to a different execution — records consumed by the current
attempt are replayed or skipped while exactly-once output silently breaks. Only
the checkpoint-id sequence exposes it.
### What the test does
New `StaleCheckpointRestoreFailoverIT` on an in-JVM two-master plus
one-worker cluster, single streaming `FakeSource` pipeline (`job.retry.times =
0`):
1. Run the job, wait for a periodic checkpoint, stop it with a savepoint.
2. Restore the same job id, let the attempt complete four checkpoints above
the savepoint, then arm a test-only sink so its **checkpoint barrier** fails
(independent of whether the source still has rows). The attempt ends `FAILED`
and its higher-id checkpoints stay stored.
3. Restore the **same savepoint again** while those higher-id checkpoints
are still on disk, and wait until the new attempt completes a checkpoint below
them.
4. Kill the active master and observe the first checkpoint the recovered
coordinator stores (recorded by a test-only local-file checkpoint storage). It
must continue the **current** attempt's sequence and must not overshoot the
superseded attempt's highest id, which would mean the recovery point was
selected by checkpoint id.
The test also asserts that the two attempts are genuinely distinguishable
before the failover (a checkpoint-id gap), so the assertion can never pass
vacuously.
### Why the existing coverage does not reach it
- `SavepointRestoreMasterFailoverIT` (#13460) covers a savepoint-restored
job whose own checkpoints are the only ones on disk; it never creates a failed
attempt from the same savepoint.
- `SavepointRestoreIT` / `SavepointClusterRestartRestoreIT` restore once and
never fail a restored attempt, so the stored checkpoint ids never overlap in
opposite write order.
- `CheckpointCoordinatorFailoverIT` / `ClusterFaultToleranceIT` never
restore from a savepoint at all.
- Retention tests (`#13663`, `#13712`) observe writes and deletes of a
single lineage.
### Verification
- Green on `dev` (`0bef81d003`): `StaleCheckpointRestoreFailoverIT` 1/1,
four consecutive runs (~31.1 s each), including a final `verify` run without
skipping spotless/checkstyle. Observed contract line:
`savepoint 2, superseded attempt's highest checkpoint 7, current attempt's
highest observed checkpoint 3, first recovered checkpoint 4`.
- Negative control: mutating
`AbstractCheckpointStorage#getLatestCheckpointFileNameByJobIdAndPipelineId` to
compare the checkpoint id embedded in the file name instead of the write-order
prefix makes the new test fail in 31.1 s:
`After a master failover the job must resume from the current restore
attempt's newest checkpoint (3 ...), not from the superseded attempt's
checkpoint 7 ... The first recovered checkpoint was 8`.
Mutation reverted and the pristine `checkpoint-storage-api` /
`checkpoint-storage-local-file` jars reinstalled (sha256 `3dce123e…` /
`3db65a13…`); test green again.
- `./mvnw -pl
seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base spotless:check`
passes.
Test-only change; no engine behavior is modified. No new issue is needed:
this guards behavior that currently holds and has no E2E coverage.
--
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]