Repository navigation
[Test][E2E] Guard stop-with-savepoint hang when precondition is rejected - #12035
Conversation
Adds a regression test for the fix in e676f46 ("[Fix][Zeta] Fix stop-with-savepoint hang in DOING_SAVEPOINT", apache#11489). Before that fix, JobMaster#savePoint() moved the job into DOING_SAVEPOINT and, if every pipeline's CheckpointCoordinator#startSavepoint() rejected the request's precondition (not all tasks ready, or the coordinator mid-shutdown), nothing ever rolled the job back to RUNNING or drove it to a terminal state, so the job hung in DOING_SAVEPOINT forever. The fix's own tests (JobMasterTest, SavePointBusySourceTest) only invoke the classification logic in isolation against fabricated, already-failed futures; they never submit a real job or drive a real CheckpointCoordinator through its actual precondition check. The existing SavepointRestoreIT/CheckpointRestoreWithStopIT only exercise the happy path. This test closes that gap by racing a real SeaTunnelClient savepoint request against real task deployment on a split master/worker cluster, using white-box polling of the master's in-process CheckpointCoordinator.isAllTaskReady flag to land reliably inside the rejection window instead of guessing a sleep duration. It then asserts the rejection is the expected precondition failure, that the job recovers to RUNNING within a bounded timeout instead of hanging, that data keeps flowing after recovery, and that a subsequent real savepoint completes normally.
DanielLeens
left a comment
There was a problem hiding this comment.
What Problem Does This PR Solve?
This is a pure test-addition PR: it adds SavepointPreconditionRecoveryIT as a regression guard for the fix in #11489 ("[Fix][Zeta] Fix stop-with-savepoint hang in DOING_SAVEPOINT"). Before that fix, if CheckpointCoordinator#startSavepoint() rejected a savepoint request because not every subtask had reported READY_START yet (TASK_NOT_ALL_READY_WHEN_SAVEPOINT), JobMaster#savePoint() had no path back to RUNNING, so the job hung in DOING_SAVEPOINT forever. The existing coverage for that fix (JobMasterTest, SavePointBusySourceTest) only drives the classification methods directly via reflection against pre-fabricated futures — none of it proves a real client-triggered savepoint landing on a real CheckpointCoordinator mid-precondition-rejection actually recovers. This PR closes that gap with a real split master/worker cluster E2E test.
Before: no test submits a real job and fires a real savepoint request while isAllTaskReady is still false, so a regression of #11489 (job wedged in DOING_SAVEPOINT) would not be caught by CI until a user hit it in production.
After: SavepointPreconditionRecoveryIT#testSavepointRecoversFromNotAllTaskReadyPrecondition races a real savepoint against real task deployment, asserts the specific rejection reason, asserts recovery to RUNNING, asserts the pipeline keeps producing data, and asserts a second (unraced) savepoint completes normally afterward.
1. Code Change Review
1.1 Core Logic Analysis
I traced every source-side claim in the PR body against current dev HEAD and they all check out:
CheckpointCoordinator#startSavepoint()(CheckpointCoordinator.java:832-842) does reject withTASK_NOT_ALL_READY_WHEN_SAVEPOINTexactly whileisAllTaskReady.get()is false (CheckpointCoordinator.java:179,839).JobMaster#savePoint()'sfinallyblock (JobMaster.java:1308-1324) does branch onisSavepointStartPreconditionFailure(...), callingrestoreRunningAfterSavepointStartFailure()(JobMaster.java:1340-1344, restoresRUNNINGonly fromDOING_SAVEPOINT) when every pipeline failure is a precondition rejection, orphysicalPlan.savepointFailed()otherwise — matching the PR description precisely.- The reliability argument for the white-box poll also holds up:
CoordinatorService#submitJobcallsjobMaster.init(...)(which synchronously creates theCheckpointManager/CheckpointCoordinatorviainitCheckPointManageratJobMaster.java:319,332) before placing the job intopendingJobQueue(CoordinatorService.java:1440-1450), andCoordinatorService#getJobMaster(jobId)(CoordinatorService.java:599-605) resolves throughpendingJobQueuefirst, thenrunningJobMasterMap. So by the first moment the test's polling helper can see a non-nullJobMaster, itsCheckpointCoordinatoralready exists withisAllTaskReady=false.
One genuine correctness/stability concern (see 2.2 for full detail — repeating the summary here since it's a core-logic finding): awaitCheckpointCoordinatorNotAllTaskReady (the file under review, lines ~278-307) gates on getJobMaster(), which is visible the moment the job enters pendingJobQueue. But finalEngineClient.savePointJob(jobId) routes to CoordinatorService#savePoint(long jobId) (CoordinatorService.java:1500-1507), which gates on a different condition: runningJobMasterMap.containsKey(jobId). A job only gets promoted from pendingJobQueue into runningJobMasterMap later, inside pendingJobSchedule() (CoordinatorService.java:401-497, promotion at line 471). Since the test's poll loop is a tight, unthrottled busy-spin (no Thread.sleep, see SavepointPreconditionRecoveryIT.java:278-298), it is capable of observing the coordinator in its "not-ready" state during the (likely very short, but real) window where the job is still sitting only in pendingJobQueue and has not yet been promoted into runningJobMasterMap. If that happens, savePointJob(jobId) will be rejected by the "job not running" branch (SavePointFailedException("...not running, save point failed")) instead of reaching CheckpointCoordinator#startSavepoint() at all — and the test's own assertion (SavepointPreconditionRecoveryIT.java:157-162, checking the rejection message contains TASK_NOT_ALL_READY_WHEN_SAVEPOINT.message()) would fail. This is a plausible, code-provable race, not merely a hypothetical — see 2.2 for severity and recommended fix.
1.2 Compatibility Impact
Fully compatible. This is a net-new test class plus a net-new test resource .conf file under src/test/resources; no production code, public API, config option, default value, or serialization format is touched. No entry needed in incompatible-changes.md.
1.3 Performance / Side-Effect Analysis
- The new test spins up an additional in-JVM two-node cluster (master + worker) — same resource footprint pattern as sibling tests in this package (
SplitClusterPendingJobLifecycleFailoverIT,CheckpointCoordinatorFailoverIT), so no new class of side effect for the CI environment. awaitCheckpointCoordinatorNotAllTaskReadyis a genuinely CPU-hot busy-spin loop with noThread.sleep/backoff, bounded at 20 seconds (SavepointPreconditionRecoveryIT.java:279-298). In the success case it should resolve in well under a second (matches the observed 8.9s total-including-cluster-bootstrap in CI), so this is low risk in practice, but it is worth calling out because a busy-spin retry loop is an unusual pattern for this codebase (existing sibling tests useAwaitilitywith a poll interval everywhere else) and it will burn a full core for however long the race takes to resolve, up to the 20s cap, if the job is ever slow to schedule.- All three cluster resources (
masterNode,workerNode,engineClient) are null-guarded and shut down infinally(lines 212-222) — no resource leak across test runs.createTestResources/FileUtils.createNewDirclears the target directory before use, so no cross-run file-system pollution either.
1.4 Error Handling and Logging
Every assertion carries a descriptive failure message (e.g., the "either the not-ready window closed... or the job failed to schedule" message on timeout at lines 299-306), which is exactly the kind of diagnosability a flaky-timing-sensitive E2E test needs when it does eventually fail in CI. No sensitive data is logged. No exceptions are silently swallowed except the intentional "keep spinning" catch (RuntimeException notYetRegistered) at lines 292-295, which is correctly scoped and commented.
2. Code Quality Assessment
2.1 Coding Standards
Clean, well-organized, thoroughly Javadoc'd (including a rare and appreciated amount of "why," not just "what," in both the class-level and method-level comments) — this exceeds the bar for E2E test documentation in this module. One very minor nit: the file imports org.apache.seatunnel.shade.org.apache.commons.lang3.tuple.ImmutablePair, while the 6 sibling files in this same test package (SplitClusterFaultToleranceIT, ClusterFailureNoRestoreIT, TextHeaderIT, etc.) all import org.testcontainers.shaded.org.apache.commons.lang3.tuple.ImmutablePair for the same utility class. Both compile and both are "shaded" per project convention, so this is not a blocker — just a one-off inconsistency with the established local pattern, not worth a formal issue.
2.2 Test Coverage and Test Stability
Coverage: this test genuinely closes the gap described in the PR body. It is the first test in the repository to drive a real CheckpointCoordinator through the actual not-ready precondition via a real client-triggered savepoint request on a real split cluster, and it verifies functional (not just cosmetic) recovery by checking the pipeline keeps producing rows, and then verifies the coordinator itself is healthy afterward via a second, successful savepoint. This is a strong, faithful regression test for the #11489 incident.
Issue 1: possible gate-mismatch race between the test's white-box poll and the production precondition check the client call actually exercises.
- Location:
seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base/src/test/java/org/apache/seatunnel/engine/e2e/SavepointPreconditionRecoveryIT.java:278-298(poll helper) and:146-162(fire savepoint + assert rejection reason), vs.seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/CoordinatorService.java:599-605(getJobMaster, checkspendingJobQueuethenrunningJobMasterMap) and:1500-1507(savePoint, checks onlyrunningJobMasterMap), with the promotion between the two happening atCoordinatorService.java:471insidependingJobSchedule(). - Problem: The test's poll helper and the production
savePointJob()call path use two different, non-identical "is this job visible yet" gates. The poll can observe aCheckpointCoordinator(created duringJobMaster#init(), which runs strictly before the job even enterspendingJobQueue) while the job is still sitting only inpendingJobQueue— i.e., beforependingJobSchedule()has promoted it intorunningJobMasterMap. If the tight busy-spin loop (no sleep at all) wins that narrow window, the very nextsavePointJob(jobId)call is rejected for "job not running" instead of reachingCheckpointCoordinator#startSavepoint(). - Potential risk: The test's own assertion at line ~157-162 (
rejectionTrace.contains(TASK_NOT_ALL_READY_WHEN_SAVEPOINT.message())) would fail with an unrelated rejection message. This would surface as an intermittent, hard-to-reproduce CI flake on this specific test — annoying and noisy for maintainers triaging unrelated PRs, but not a false sense of safety: if this races, the test fails loudly rather than passing when it shouldn't, so it does not mask a real regression of #11489. - Best improvement: Poll the exact same gate
CoordinatorService#savePoint()checks —runningJobMasterMap.containsKey(jobId)— viaReflectionUtils.getField(coordinatorService, "runningJobMasterMap"), rather than relying ongetJobMaster()'s broader (pendingJobQueueORrunningJobMasterMap) visibility. That would make the poll and the subsequent client call agree on the same precondition window by construction, eliminating the race rather than just making it statistically unlikely. - Severity: Medium (real, code-provable mechanism; narrow window in an in-JVM same-process cluster makes it unlikely to fire often, and the one observed CI run passed cleanly in 8.9s; does not risk false-negative masking of the actual incident, only occasional false-positive CI noise).
- Raised by another reviewer: No.
Rating: Risk present (per the mandatory stability rating — not "Stable" because of Issue 1 above; not "High risk" because the mechanism cannot cause the test to silently pass through a real regression, only to occasionally fail for an unrelated reason).
Everything else in the stability checklist is clean: no hard sleeps (Awaitility with sensible timeouts and poll intervals is used throughout except for the one busy-spin, which is bounded and self-diagnosing on timeout), no shared mutable static state between test methods (this is the only test method in the class), and cluster resources are fully cleaned up in finally.
2.3 Documentation Updates
Not applicable — test-only change with no user-facing behavior, config, or API surface.
3. Architectural Soundness
3.1 Elegance of the Solution
The white-box reflection-based polling approach, gated on the exact internal flag the production precondition check reads, is a thoughtful way to deterministically land inside a narrow timing window without guessing a sleep duration — a good pattern for this class of "hit exactly this internal state" regression test, modulo the gate-mismatch nuance in Issue 1.
3.2 Maintainability
High. The Javadoc is unusually thorough about why each step is reliable, which will make this test much easier to triage the next time someone touches savepoint scheduling and it starts failing.
3.3 Extensibility
The pattern (spin-poll an internal field via ReflectionUtils, fire a real client action, assert on both the immediate rejection and the eventual recovery) is reusable for future precondition-race regression tests in this package.
3.4 Historical-Version Compatibility
Not applicable — no serialization, checkpoint format, or protocol change; test-only.
4. Issue Summary
Issue 1 (Medium) — see 2.2 above: possible gate mismatch between the test's getJobMaster()-based poll and the runningJobMasterMap-only gate CoordinatorService#savePoint() actually checks, which could occasionally cause a spurious assertion failure (not a missed regression) under an unlucky timing race.
No other blocking issues found.
5. Merge Recommendation
Conclusion: Ready to merge after fixes
-
Blockers - must be fixed
- None strictly required to merge — Issue 1 is a Medium-severity flakiness risk, not a correctness gap in what the test actually proves when it does pass.
-
Recommended fixes - non-blocking
- Issue 1: harden
awaitCheckpointCoordinatorNotAllTaskReadyto pollrunningJobMasterMapdirectly (matching the exact gateCoordinatorService#savePoint()checks) instead ofgetJobMaster()'s broader visibility, to remove the narrow race window rather than rely on it being statistically unlikely to fire. - Optional: align the
ImmutablePairimport with theorg.testcontainers.shaded...convention used by the 6 sibling files in this package, purely for local consistency.
- Issue 1: harden
Overall this is a well-researched, well-justified regression test that genuinely closes a real coverage gap for a real prior incident (#11489), and its source-tracing in the PR description checks out line-for-line against current dev. Nice work digging into the exact happens-before relationship between JobMaster#init() and job visibility to make the poll reliable — I'd just like to see that same rigor applied one level deeper so the poll's gate matches the client call's gate exactly, rather than being merely "usually" narrower. Happy to see this land once that's addressed (or discussed, if I'm missing something about why the two gates can't actually diverge in practice).
DanielLeens
left a comment
There was a problem hiding this comment.
What Problem Does This PR Solve?
Follow-up to my prior review on this PR: this remains a pure test-addition PR adding SavepointPreconditionRecoveryIT as a regression guard for the fix in #11489 ("[Fix][Zeta] Fix stop-with-savepoint hang in DOING_SAVEPOINT"). Before that fix, if CheckpointCoordinator#startSavepoint() rejected a savepoint request because not every subtask had reported READY_START yet (TASK_NOT_ALL_READY_WHEN_SAVEPOINT), JobMaster#savePoint() had no path back to RUNNING, so the job hung in DOING_SAVEPOINT forever. This test races a real client-triggered savepoint against real task deployment on a real split master/worker cluster, landing inside the not-ready precondition window via white-box polling, and proves the job recovers to RUNNING, keeps producing data, and that the coordinator itself is subsequently healthy (a second savepoint succeeds).
Since my last review (at commit c72fea8), one new commit landed: e1e417e837a ("[Test][E2E] Align savepoint precondition gate"). I re-reviewed the entire PR from scratch against the current head as required, not just the incremental diff.
Before: no test submitted a real job and fired a real savepoint request while isAllTaskReady was still false, so a regression of #11489 would not be caught by CI until a user hit it in production.
After: SavepointPreconditionRecoveryIT#testSavepointRecoversFromNotAllTaskReadyPrecondition closes that gap, and the new commit also closes the one gap I found in it.
1. Code Change Review
1.1 Core Logic Analysis
I re-traced every source-side claim against current dev HEAD from scratch:
CheckpointCoordinator#startSavepoint()(CheckpointCoordinator.java:832-843) rejects withTASK_NOT_ALL_READY_WHEN_SAVEPOINTexactly whileisAllTaskReady.get()is false (field atCheckpointCoordinator.java:179), and does so viacompletableFutureWithError(...), which completes the returned future immediately with the exception — confirmed this is not a case where the future/response is left pending. This directly answers the task's core question: the precondition-rejection path genuinely completes the response rather than hanging by itself; the pre-#11489 bug was entirely inJobMaster's handling of that already-completed exceptional future, not inCheckpointCoordinator.JobMaster#savePoint()(JobMaster.java:1284-1327) wraps the whole body infinally. WhenwaitSavepointCompleted(...)reportssavepointCompleted = false(JobMaster.java:1301,1366-1389) andgetSavepointFailureException(...)finds a failure, the try block throwsSeaTunnelEngineException(JobMaster.java:1304-1306) — but thefinallyblock still runs (correct Java semantics:finallyexecutes even when the try throws), callingisSavepointStartPreconditionFailure(...)(JobMaster.java:1310, defined at1401-1411) which returns true only when no pipeline reachedSUSPENDand every exception's root cause is aCheckpointExceptionwith reasonTASK_NOT_ALL_READY_WHEN_SAVEPOINTorCHECKPOINT_COORDINATOR_SHUTDOWN(JobMaster.java:1417-1427). When true,restoreRunningAfterSavepointStartFailure()(JobMaster.java:1340-1344) flips the job fromDOING_SAVEPOINTback toRUNNING. This is exactly the fix the test guards.CheckpointException's message is built directly fromfailureReason.message()(CheckpointException.java:29-31), andCheckpointCloseReason.TASK_NOT_ALL_READY_WHEN_SAVEPOINT.message()is the literal string"Task not all ready, savepoint error"(CheckpointCloseReason.java:29).ExceptionUtils.getMessage(...)prints the full stack trace including causes (ExceptionUtils.java:29-38), so the test'srejectionTrace.contains(TASK_NOT_ALL_READY_WHEN_SAVEPOINT.message())assertion (SavepointPreconditionRecoveryIT.java:151-156) genuinely proves the specific precondition was hit, not just "some exception happened."
Issue 1 from my prior review is now fixed. I had flagged that awaitCheckpointCoordinatorNotAllTaskReady's old poll helper used CoordinatorService#getJobMaster(jobId) (CoordinatorService.java:597-603), which resolves through pendingJobQueue before runningJobMasterMap — but the real client call, CoordinatorService#savePoint(long) (CoordinatorService.java:1500-1507), gates only on runningJobMasterMap.containsKey(jobId). Since jobMaster.init() (which creates the CheckpointCoordinator) runs before the job even enters pendingJobQueue (CoordinatorService.java:1444-1450), while runningJobMasterMap.put(jobId, jobMaster) only happens later, inside pendingJobSchedule() at CoordinatorService.java:471 — strictly before the async jobMaster.run() dispatch at CoordinatorService.java:476-486 — there was a real (if narrow) window where the old poll could see a non-null JobMaster via getJobMaster() while the job was still only in pendingJobQueue, not yet in runningJobMasterMap. Firing savePointJob() in that window would hit the unrelated "job not running" rejection (SavePointFailedException, CoordinatorService.java:1502-1505) instead of the intended precondition, causing a spurious CI failure (not a false pass).
Commit e1e417e837a fixes this correctly: awaitCheckpointCoordinatorNotAllTaskReady (SavepointPreconditionRecoveryIT.java:272-301) now calls the new getRunningJobMaster (:323-334), which reads runningJobMasterMap directly via ReflectionUtils.getField(server.getCoordinatorService(), "runningJobMasterMap") and does .get(jobId) — I confirmed runningJobMasterMap is declared Map<Long, JobMaster> (CoordinatorService.java:184), so the long jobId autoboxes correctly and the lookup is exact. This is now the identical gate CoordinatorService#savePoint() checks, by construction, not merely "usually narrower" — the race is eliminated rather than just made statistically unlikely, which is precisely what I asked for. I also checked ReflectionUtils.getField (seatunnel-common/.../ReflectionUtils.java:44-60): it walks up the superclass chain and does a plain field read with setAccessible(true), so it will correctly find the field regardless of which class in the hierarchy declares it. No new issue introduced by this change.
1.2 Compatibility Impact
Fully compatible. Net-new test class plus a net-new test resource .conf file under src/test/resources; no production code, public API, config option, default value, or serialization format is touched. No entry needed in incompatible-changes.md.
1.3 Performance / Side-Effect Analysis
- Same footprint as sibling in-JVM two-node cluster tests in this package (
SplitClusterPendingJobLifecycleFailoverIT,CheckpointCoordinatorFailoverIT). awaitCheckpointCoordinatorNotAllTaskReadyremains a CPU-hot busy-spin loop with noThread.sleep/backoff, bounded at 20 seconds (SavepointPreconditionRecoveryIT.java:272-292) — this is unchanged by the new commit and was already noted as low-risk-but-worth-mentioning in my prior review (every other test in this package usesAwaitilitywith a poll interval). Still non-blocking: it is bounded, self-diagnosing on timeout (:293-300), and each reflective lookup underneath is cheap.- All cluster resources (
masterNode,workerNode,engineClient) are null-guarded and shut down infinally(:206-216) — no resource leak.FileUtils.createNewDirclears the target directory before use — no cross-run filesystem pollution.
1.4 Error Handling and Logging
Every assertion carries a descriptive failure message. No sensitive data logged. The intentional catch (RuntimeException notYetRegistered) (:286-289) is correctly scoped (pipeline-not-yet-registered is the only expected transient condition there) and commented.
2. Code Quality Assessment
2.1 Coding Standards
Clean, thoroughly Javadoc'd, and the updated Javadoc on awaitCheckpointCoordinatorNotAllTaskReady/getRunningJobMaster (:258-267, :317-322) now correctly explains why getJobMaster() is deliberately avoided — a good "why not the obvious API" comment. Same pre-existing minor nit as last review, still non-blocking: this file imports org.apache.seatunnel.shade.org.apache.commons.lang3.tuple.ImmutablePair while the 6 sibling files in this package import org.testcontainers.shaded...ImmutablePair for the same utility. Not worth a formal issue.
2.2 Test Coverage and Test Stability
Coverage is unchanged and remains strong: this is the first test in the repository driving a real CheckpointCoordinator through the actual not-ready precondition via a real client-triggered savepoint on a real split cluster, verifying functional (not cosmetic) recovery.
Does the test genuinely prove the hang is fixed, or could it pass "by accident" under the old bug? Genuinely proves it. The core regression assertion (:164-175) is an Awaitility.await().atMost(30, SECONDS)...untilAsserted(() -> assertEquals(RUNNING, ...)). Under the pre-#11489 bug, the job would stay in DOING_SAVEPOINT forever after the precondition rejection (there was no other path back to RUNNING or to a terminal state), so this specific assertion would time out and fail after 30 seconds — it is a real bounded-wait assertion, not a tautology, not an existence check, and not something that could pass by coincidence with the bug still present. The subsequent "still producing data" check and the "second savepoint succeeds and reaches SAVEPOINT_DONE" check add further, independent proof that recovery is functionally complete, not just a cosmetic status flip.
Mandatory stability rating (Section 5.10.2): Stable. The one previously-open concern (Issue 1, the gate mismatch between the poll and the production savePoint() check) is fully resolved by e1e417e837a — the poll now reads the exact same runningJobMasterMap the RPC endpoint gates on, by construction, eliminating the race rather than relying on its statistical rarity. No Thread.sleep-based waits are used for correctness-relevant synchronization anywhere in the test; all recovery/completion assertions use Awaitility with bounded timeouts and poll intervals. The one busy-spin loop (awaitCheckpointCoordinatorNotAllTaskReady) is bounded (20s) and self-diagnosing — a style nit, not a stability defect, since it can only fail loudly (timeout) rather than silently pass. No shared mutable static state between test methods (single test method). Resources are fully cleaned up in finally.
2.3 Documentation Updates
Not applicable — test-only change, no user-facing behavior/config/API surface.
3. Architectural Soundness
3.1 Elegance of the Solution
The white-box reflection-based polling, now gated on the exact internal state the production RPC path checks (both for job-visibility and for the precondition flag itself), is a clean, race-free way to deterministically land inside a narrow timing window. The fix in e1e417e837a is minimal and targeted — it changes only the visibility gate, not the polling structure or the assertions.
3.2 Maintainability
High, and improved further: the new Javadoc explicitly documents why getJobMaster() is unsuitable here, which will save the next maintainer from reintroducing the same race if they ever "simplify" this back to the public accessor.
3.3 Extensibility
The pattern (spin-poll an internal field via ReflectionUtils, matched exactly to the gate the client-facing RPC checks, then fire a real client action and assert on both immediate rejection and eventual recovery) is reusable for future precondition-race regression tests in this package.
3.4 Historical-Version Compatibility
Not applicable — test-only, no serialization/checkpoint format/protocol change.
4. Issue Summary
No open issues. Issue 1 from my prior review (Medium — gate mismatch between the poll's getJobMaster() and the RPC's runningJobMasterMap-only check) is resolved by commit e1e417e837a, verified against current source.
5. Merge Recommendation
Conclusion: Ready to merge
-
Blockers - must be fixed
- None.
-
Recommended fixes - non-blocking
- Optional (repeated from last review, still purely cosmetic): align the
ImmutablePairimport with theorg.testcontainers.shaded...convention used by the 6 sibling files in this package.
- Optional (repeated from last review, still purely cosmetic): align the
This is a well-researched regression test for a real prior incident (#11489), and the follow-up commit precisely and correctly addresses the one race I flagged, by matching the poll's visibility gate to the exact map the production RPC endpoint checks rather than relying on the old gate's window being merely small. I re-verified every source-side claim (precondition rejection, future completion, finally-block recovery routing, message propagation, and the corrected gate) against current dev/PR head from scratch, and it all checks out line-for-line. Approving.
CI: the fork's Build check is SUCCESS as of the current head; mergeStateStatus is BLOCKED, which per branch-protection on this repo reflects pending required review/approval rather than any CI or merge-conflict problem (PR is reported MERGEABLE) — no rebase/sync action needed from the author.
|
Non-blocking: A small race remains between checking isAllTaskReady and submitting the savepoint request. This is acceptable for now, but if the test becomes flaky, we should add deterministic synchronization in a follow-up. |
What this guards
This adds an E2E regression test for the fix in
e676f46dc73a49e410661ccb49b325d6871eb70a("[Fix][Zeta] Fix stop-with-savepoint hang in DOING_SAVEPOINT", #11489).The bug:
JobMaster#savePoint()moved the job intoDOING_SAVEPOINTand then triggered every pipeline'sCheckpointCoordinator#startSavepoint(). If a pipeline's coordinator rejected the request's precondition (TASK_NOT_ALL_READY_WHEN_SAVEPOINTwhen not all subtasks had reportedREADY_STARTyet, orCHECKPOINT_COORDINATOR_SHUTDOWNif the coordinator was mid-shutdown), nothing ever rolled the job back toRUNNINGor drove it to a terminal state — the job hung inDOING_SAVEPOINTforever.The fix classifies every pipeline's savepoint-completion outcome in
JobMaster#waitSavepointCompleted/isSavepointStartPreconditionFailure. When every failure is a pre-start precondition rejection and no pipeline reachedSUSPEND,restoreRunningAfterSavepointStartFailure()restores the job toRUNNINGso the caller can retry. Any other failure instead drives the job to a terminal state through the newPhysicalPlan#savepointFailed()fallback.What coverage was missing
The fix's own accompanying tests (
JobMasterTest,SavePointBusySourceTest) are unit-level: they invoke the classification methods directly via reflection against fabricated, already-failedCompletableFutures — they never submit a real job or drive a realCheckpointCoordinatorthrough its actual precondition check.SavepointRestoreITandCheckpointRestoreWithStopITin the same package only exercise the happy path (savepoint succeeds, then restore from it). None of the existing coverage proves that a real, client-triggered savepoint request landing on a realCheckpointCoordinatorwhile it genuinely rejects the not-ready precondition actually recovers instead of hanging.What the new test does
SavepointPreconditionRecoveryIT(in-JVM split master/worker cluster, following the house style ofSplitClusterPendingJobLifecycleFailoverIT/CheckpointCoordinatorFailoverIT):SeaTunnelClient.CheckpointCoordinator(reached throughSeaTunnelServer/CoordinatorService, exactly as other tests in this package already do) via reflection on itsisAllTaskReadyfield — the exact flagstartSavepoint()checks — until the coordinator exists but has not yet observed every subtask reportREADY_START.engineClient.savePointJob(jobId)in the very next statement so it arrives on the master while the precondition is still false.TASK_NOT_ALL_READY_WHEN_SAVEPOINTprecondition (proving the intended race was actually hit, not some unrelated failure).RUNNINGwithin a bounded timeout instead of hanging inDOING_SAVEPOINT.isAllTaskReadyhas settled true) now succeeds normally and drives the job toSAVEPOINT_DONE— proving the checkpoint coordinator itself is fully healthy after the earlier rejection, not just superficially reportingRUNNING.Why the trigger is reliable
CheckpointCoordinatorobjects are created synchronously insideJobMaster#init(), and by the time they exist the job is already registered inCoordinatorService#runningJobMasterMap(that registration strictly happens-before the asynchronousJobMaster#run()/init()call that creates the coordinators). So a savepoint request fired the moment the coordinator becomes visible is guaranteed to reach the real precondition check inCheckpointCoordinator#startSavepoint()— not rejected earlier for the unrelated "job not running" reason. Task deployment, worker startup, and theREADY_STARTreport round trip all happen strictly after coordinator creation and take real wall-clock time (worker RPC, classloading, thread startup), giving the white-box poll a wide safety margin over blind timing.Test plan
./mvnw spotless:apply -pl seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base -am -nsu— passed../mvnw install -pl 'seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base,!seatunnel-engine/seatunnel-engine-ui' -am -nsu -Dmaven.gitcommitid.skip=true -DskipTests -Dspotless.check.skip=true -T 3C—BUILD SUCCESS, withseatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-basemodule reportingSUCCESS. Directly confirmed the new test class actually compiled:target/test-classes/org/apache/seatunnel/engine/e2e/SavepointPreconditionRecoveryIT.classexists. (seatunnel-engine-uiexcluded since it is unmodified by this change and pulling it into the reactor triggers an unrelatednpm installthat has no network access in this environment; its already-published.m2artifact is used instead.)CheckpointCoordinator#startSavepoint,JobMaster#waitSavepointCompleted/isSavepointStartPreconditionFailure/restoreRunningAfterSavepointStartFailure,CoordinatorService#savePoint/pendingJobSchedule) this test exercises. CI on this PR is the source of truth for actual execution.🤖 Generated with Claude Code