zhangshenghang opened a new pull request, #13783:
URL: https://github.com/apache/seatunnel/pull/13783
Yes, I am contributing this change to Apache SeaTunnel under the project's
contribution conventions.
## What this PR changes
Fixes #13782: a stop-with-savepoint taken on a BATCH job whose **periodic
checkpointing is disabled** (no `env.checkpoint.interval`) could not be
restored — the restore path silently ignored the stored savepoint and replayed
the whole source.
- `CheckpointManager` now loads the restore base when a restore can actually
have checkpoint data, not only when `checkpointConfig.isCheckpointEnable()` is
true:
```java
boolean canRestoreCheckpointData =
isRestoreJob && (checkpointConfig.isCheckpointEnable() ||
restoreSourceJobId != null);
```
A periodic checkpoint scheduler and a user-requested savepoint are
independent: `CheckpointCoordinator#startSavepoint` has no checkpoint-enable
gate, so a savepoint is stored for such a job (and `clearCheckpointIfNeed`
never deletes it), but the server-side restore dropped it. A job that is merely
restarted after a master failover without a restore source still has nothing to
load, so that path is unchanged.
- Adds the E2E guard `BatchSavepointRestoreCheckpointDisabledIT` with its
counting sink fixture and job template.
## The contract under test
1. A BATCH `FakeSource -> test sink` pipeline (parallelism 1, 6000 rows, 1
ms per row) runs with **no** `env.checkpoint.interval`, so the running job
completes no periodic checkpoint at all — asserted through
`JobClient#getCheckpointData(jobId, RestoreMode.CHECKPOINT)` while the job is
`RUNNING`.
2. A client `savePointJob` request completes, the job ends `SAVEPOINT_DONE`,
and the savepoint is readable through `JobClient#getCheckpointData(jobId,
RestoreMode.SAVEPOINT)`.
3. The savepoint is taken while the single `FakeSource` split still has
unread rows: the original incarnation writes 4096 of the 6000 rows
(`FakeSourceReader#MAX_ROWS_PER_POLL`), so a replay is distinguishable from a
resume.
4. `restoreExecutionContext` with the same job id reaches `FINISHED`, and
the restored incarnation must **resume** the saved split instead of replaying
it: the rows written by the restored run are fewer than 6000, and the two
incarnations together cover the whole split. Before the fix the restored run
wrote all 6000 rows (`The restored job re-read the whole source split instead
of resuming from the savepoint: restored rows=6000, source rows=6000`); after
the fix it writes the remaining 1904 rows, and the original 4096 + restored
1904 add up to exactly 6000.
5. The savepoint survives the restore and is still readable, because it is
the job's only recovery point.
The sink fixture only appends one file per writer instance with a per-row
delay, so source and sink stay plain fixtures; no Transform, SQL semantics,
connector or format behaviour is involved.
## Why existing coverage misses it
- `SavepointRestoreIT`, `SavepointClusterRestartRestoreIT`,
`MultiPipelineSavepointRestoreIT`, `CheckpointRestoreWithStopIT` and the rest
of the savepoint suite all restore jobs whose periodic checkpointing is
enabled, so the load gate is always true and the disabled branch is never
exercised.
- The checkpoint-disabled BATCH path is only covered by
`JobExecutionIT#testLastCheckpointError` style tests, which never take or
restore a savepoint.
- #13497 is a different defect in the same configuration space (a master
failover starting checkpoint scheduling on such a job); it does not touch the
restore load gate.
- #13439 / #13440 cover a restore with **no** checkpoint data at all; here
the data exists and is silently unused.
## Verification
- E2E reproduces on `origin/dev` (`231face16f` parent):
`BatchSavepointRestoreCheckpointDisabledIT` fails in 27.4 s with the replay
assertion.
- With the fix: green twice, 19.2 s and 19.5 s; `original run 4096 rows,
restored run 1904 rows` both times.
- Regression guard for the normal path: `MultiPipelineSavepointRestoreIT`
green (17.7 s) with the fixed `engine-server`.
- Unit tests: `CheckpointManagerTest`, `CheckpointCoordinatorTest`,
`StateStoreCheckpointIDCounterTest` — 31 tests, all pass.
- `spotless:check` (bound to `validate`) passes for both modules; `git diff
--check` clean.
- Run command:
`mvn -o -pl
seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base verify
-DskipUT=true -DskipIT=false
-Dit.test=BatchSavepointRestoreCheckpointDisabledIT -DfailIfNoTests=false`
--
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]