Repository navigation
[Test][Zeta] Add E2E coverage for savepoint barrier injection against a busy source (apache/seatunnel#11473) - #12141
Conversation
…source (apache#11473) Issue apache#11473 reported that a REST stop-job with isStopWithSavePoint=true against a plain streaming FakeSource -> Console job never completed and left the job in DOING_SAVEPOINT forever. PR apache#11489 fixed it on two ends: FakeSourceReader#pollNext now emits bounded batches and requeues the rest of the split, so the checkpoint lock that SourceFlowLifeCycle#triggerBarrier needs is released between batches and the savepoint barrier can be injected mid-split; and JobMaster#savePoint leaves DOING_SAVEPOINT deterministically when a savepoint cannot complete. The fix's own SavePointBusySourceTest reproduces the busy split only in a single in-process server, calling CoordinatorService#savePoint directly, so the barrier never crosses a node boundary and no client is involved. SavepointPreconditionRecoveryIT (apache#12035) covers a different branch of the same fix, the TASK_NOT_ALL_READY_WHEN_SAVEPOINT precondition rejection, which never involves a busy source. The literal apache#11473 mechanism had no E2E coverage through the real multi-node path. SavepointBusySourceBarrierIT runs the issue's reproduction job (one 100,000,000-row FakeSource split into a Console sink) on a split master/worker cluster, waits until job metrics show the reader actively emitting its split, fires a real SeaTunnelClient#savePointJob request, and requires it to complete within a bound that deliberately exceeds the job's checkpoint.timeout, so a starved barrier fails cleanly instead of hanging. It proves the barrier landed mid-split by requiring the finished job's SourceReceivedCount to sit strictly between the last live sample and the split size, then restores the job from that savepoint (RestoreMode.SAVEPOINT), verifies the restored source resumes emitting, and takes a second stop-with-savepoint against the restored, still-busy source. Passed four consecutive local runs (17.9-18.7s each); both barriers landed on a 4096-row batch boundary with the split far from drained. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
DanielLeens
left a comment
There was a problem hiding this comment.
What Problem Does This PR Solve?
- User pain point: #11473 reported that
stop-job --savepointagainst a plain streamingFakeSource -> Consolejob never completed and left the job stuck inDOING_SAVEPOINTforever, holding its slots hostage. The fix landed in #11489, but no test exercised the actual multi-node mechanism end to end: the existingSavePointBusySourceTestreproduces the busy split only inside a single in-process server (callingCoordinatorService#savePointdirectly, no client, no node boundary), andSavepointPreconditionRecoveryITcovers a completely different branch of the same fix (theTASK_NOT_ALL_READY_WHEN_SAVEPOINTprecondition rejection). - Fix approach: this PR adds
SavepointBusySourceBarrierIT, which drives the literal #11473 reproduction job (one 100,000,000-rowFakeSourcesplit into aConsolesink) through a real split master/worker cluster, waits until job metrics prove the source is actively mid-split, fires a realSeaTunnelClient#savePointJobrequest, and requires it to complete within a bound that deliberately exceedscheckpoint.timeoutso a starved barrier fails cleanly instead of hanging. It then proves the savepoint is genuinely usable by restoring the job from it and repeating the same busy-split savepoint against the restored run. - One-sentence summary: a well-targeted, real end-to-end regression test that closes the coverage gap left by #11489 for the exact scenario reported in #11473.
1. Code Change Review
1.1 Core Logic Analysis
This is a test-only addition (one new *IT class + one new .conf resource, no production code touched). I traced every claim the test's javadoc makes against the current dev head (f0c459055706, fetched fresh for this review) rather than trusting the PR description at face value:
FakeSourceReader#pollNext(seatunnel-connectors-v2/connector-fake/.../FakeSourceReader.java) genuinely caps emission atMAX_ROWS_PER_POLL = 4096per call and requeues the remainder of the split, releasingoutput.getCheckpointLock()between batches — exactly the mechanism the test's javadoc describes and the mechanism that starved the barrier pre-fix.JobMaster#savePoint()(seatunnel-engine-server/.../master/JobMaster.java:1283) has the deterministicfinallybranch the test relies on: when the savepoint doesn't complete and it isn't the "not all tasks ready" precondition, it callsphysicalPlan.savepointFailed()instead of leaving the job stuck inDOING_SAVEPOINT.
Runtime path exercised by the test:
SeaTunnelClient#savePointJob(jobId)
-> JobMaster#savePoint() [master]
-> checkpointManager.triggerSavePointsAndWaitComplete()
-> CheckpointBarrierTriggerOperation dispatched to worker
-> SourceFlowLifeCycle#triggerBarrier acquires checkpoint lock
(contends with FakeSourceReader#pollNext's per-batch lock hold)
-> waitSavepointCompleted() blocks the test's async CompletableFuture
-> job reaches SAVEPOINT_DONE, CoordinatorService releases the JobMaster
-> engineClient.getJobMetricsSummary(jobId) reads the finished-job SourceReceivedCount
The mid-split proof (rowsAtSavepoint < SPLIT_ROW_NUM) and the "metrics were actually captured" proof (rowsAtSavepoint >= rowsBeforeSavepoint) are both real, non-vacuous assertions: if the metrics path returned stale/zero data after release, the first assertion would fail loudly rather than pass by accident. I also confirmed getJobMetricsSummary/restoreExecutionContext(filePath, jobConfig, seaTunnelConfig, jobId) signatures match SeaTunnelClient exactly as used.
I additionally confirmed via the real CI run (fork run 34012353379, job "engine-v2-it (11, ubuntu-latest)") that this exact test executed and passed: Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 19.617 s. This is not a theoretical trace — the barrier-mid-split scenario was actually reproduced and actually passed in CI.
1.2 Compatibility Impact
Fully compatible. No production code, config option, protocol, or serialization format is touched. Purely additive test coverage.
1.3 Performance / Side-Effect Analysis
No production hot path is touched. The test itself spins up an isolated two-node Hazelcast cluster per run (standard pattern for this test suite) and is cleaned up in a finally block (engineClient.close(), both nodes' shutdown()), so no thread/port/resource leak across test runs. Measured CI cost is modest (~20s), well inside typical E2E budgets for this module.
1.4 Error Handling and Logging
readSourceReceivedCount deliberately swallows RuntimeException from a metrics RPC that can transiently fail while task groups are being deployed/torn down, logs it at WARN, and returns -1 so the surrounding Awaitility poll simply retries rather than aborting on a single transient miss — this is the correct pattern for polling code and doesn't hide a real failure (the poll's own assertion still requires eventual success within the bound).
No issues found here.
2. Code Quality Assessment
2.1 Coding Standards
Comments are thorough and exceed the bar: every non-trivial method and constant has a javadoc explaining the "why" (e.g. why SAVEPOINT_COMPLETION_TIMEOUT_SECONDS deliberately exceeds checkpoint.timeout, why the restore reuses the same job id and what awaitJobReleasedByCoordinator protects against). License header present. No wildcard imports.
2.2 Test Coverage and Test Stability
Stability rating: Stable.
- All waits are
Awaitility-based with explicit, generous bounds (120s) and short poll intervals (200ms) — no rawThread.sleepanywhere in the test. - No shared/static mutable state between test runs.
- Resources (client, master node, worker node) are deterministically released in
finally. - The mid-split race window is constructed deterministically (100M rows at 4096/batch with a 10ms minimum read interval physically cannot drain within the test's bounds), not by chance timing — this is what makes the "mid-split" assertion reliable rather than a coin flip.
- Verified against a real, currently-green CI run rather than only against a diff.
This test closes a real, previously-uncovered gap: no existing test exercised the busy-split savepoint scenario across a real node boundary with a real client.
2.3 Documentation Updates
Not applicable — test-only change, no user-visible behavior changed.
3. Architectural Soundness
3.1 Elegance of the Solution
Precise fix for a real coverage gap. The test is scoped exactly to the mechanism #11489 fixed and deliberately avoids re-testing the precondition-rejection branch already covered by SavepointPreconditionRecoveryIT.
3.2 Maintainability
High. The javadoc is detailed enough that a future maintainer investigating a savepoint regression would understand both the historical bug and why this specific test exists without needing to read #11473/#11489 first.
3.3 Extensibility
The helper methods (awaitSourceActivelyEmitting, stopWithSavepointWithinBound, awaitJobReleasedByCoordinator) are generically useful and could be reused by future savepoint/checkpoint E2E tests in this package with minimal changes.
3.4 Historical-Version Compatibility
Not applicable — no serialization, checkpoint format, or protocol change involved.
4. Issue Summary
No issues found — table intentionally empty.
| Number | Issue | Location | Severity |
|---|---|---|---|
| — | None found | — | — |
5. Merge Recommendation
Conclusion: Ready to merge
- Blockers — None.
- Recommended fixes — non-blocking:
- Purely optional: the per-node
getSeaTunnelConfigcluster-bootstrap boilerplate is duplicated with sibling ITs likeSavepointPreconditionRecoveryIT; a shared test utility could reduce duplication in the future, but that's a nice-to-have, not something this PR should be blocked on.
- Purely optional: the per-node
Overall assessment: this is exactly the kind of white-box, real-path regression test this project should have more of — it traces a specific historical bug through the real client/master/worker boundary rather than unit-testing the fix in isolation, and I independently verified both the production-code premise (the fix is genuinely present in current dev) and the CI execution (the test actually ran and passed, not just compiled). No concerns. Approving.
Purpose of this pull request
Add E2E regression coverage for the literal mechanism behind #11473 ("[Bug] [Zeta] stop-job with savepoint hangs in DOING_SAVEPOINT"), fixed by #11489: a savepoint requested while the source is busy emitting a very large split must still get its barrier injected and complete, through the real multi-node path.
The gap
#11489fixed the hang on two ends:FakeSourceReader#pollNextnow emits at mostMAX_ROWS_PER_POLLrows per call and requeues the remainder of the split, so the checkpoint lock thatSourceFlowLifeCycle#triggerBarrierneeds is released between batches; andJobMaster#savePointnow leavesDOING_SAVEPOINTdeterministically when a savepoint cannot complete.Existing coverage of that fix:
SavePointBusySourceTest(seatunnel-engine-server): reproduces the busy split, but only inside a single in-process server and by callingCoordinatorService#savePointdirectly. The barrier never crosses a node boundary and no client is involved.SavepointPreconditionRecoveryIT([Test][E2E] Guard stop-with-savepoint hang when precondition is rejected #12035): E2E, but it exercises a different branch of the same fix, theTASK_NOT_ALL_READY_WHEN_SAVEPOINTprecondition rejection that restores the job to RUNNING. No busy source and no starved barrier are involved there.The #11473 mechanism itself, a barrier that has to be injected into a source mid-split, with the trigger dispatched over the network by
CheckpointBarrierTriggerOperationand the request coming from a real client, had no E2E coverage.What the new test does
SavepointBusySourceBarrierIT(connector-seatunnel-e2e-base, same harness asSavepointPreconditionRecoveryIT):stream_fake_busy_split_to_console_savepoint.conf: oneFakeSourcesplit of 100,000,000 rows,split.read-interval = 10,checkpoint.interval = 10000,checkpoint.timeout = 60000, Console sink withlog.print.data = false).SourceReceivedCountis positive and still growing between two samples, i.e. the reader is provably mid-split, then fires a realSeaTunnelClient#savePointJobfrom a separate thread.TimeoutExceptionis reported as the [Bug] [Zeta] stop-job with savepoint hangs in DOING_SAVEPOINT #11473 hang; anExecutionExceptionis the [Fix][Zeta] Fix stop-with-savepoint hang in DOING_SAVEPOINT #11489 failure exit, which is equally a regression here), then requiresSAVEPOINT_DONE.SourceReceivedCountrecorded in the finished-job history must be at least the last live sample and strictly below the split size. Pre-fix the barrier could only pass after the whole split drained (or never, once the checkpoint expired).restoreExecutionContext(RestoreMode.SAVEPOINT, which only accepts a savepoint-type checkpoint), waits for the restored source to emit again, and takes a second stop-with-savepoint against the restored, still-busy source.The bound of 120 s deliberately exceeds the job's
checkpoint.timeout(60 s), so a starved barrier surfaces as a checkpoint expiry and a failed request instead of a silent hang past the bound.Why it is not flaky
CoordinatorService#submitJobtreats the still-registered id as already running and silently skips the restore.Verification
Local run (macOS, JDK 8, full
-aminstall of the upstream modules from this branch, thenverify -pl connector-seatunnel-e2e-base -DskipUT=true -DskipIT=false -Dit.test=SavepointBusySourceBarrierIT), 4 consecutive passes:Trace from run 4 (checkpoint coordinator / job master at INFO):
Both barriers landed on a 4096-row batch boundary (77824 = 19 x 4096, 118784 = 29 x 4096) with the split far from drained, which is exactly the lock release added by #11489. No
timeout checkpoint/CHECKPOINT_EXPIREDevents, no transient metric failures../mvnw spotless:check -pl seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-basepasses.Does this PR introduce any user-facing change?
No. Test-only: one new IT class and one new test job config under
connector-seatunnel-e2e-base/src/test.How was this patch tested?
See Verification above; CI runs the new IT as part of the engine E2E module.
Check list
release-note.🤖 Generated with Claude Code