Repository navigation
[Test][E2E] Add regression coverage for task stuck in CANCELING when worker crashes mid-cancel - #12030
Conversation
DanielLeens
left a comment
There was a problem hiding this comment.
What Problem Does This PR Solve?
- User pain point: the fix in #10729 ("[Fix][Zeta] prevent cancel stuck and downgrade tmp cleanup failure") closed a real bug where a task vertex could stay
CANCELINGforever if its worker crashed after the cancel RPC was sent but before the ack arrived, yet that fix shipped with no dedicated regression test reproducing the original multi-node timing/race at the engine level. - Fix approach: adds
SplitClusterFaultToleranceIT#testStreamJobCancelResolvesWhenWorkerCrashesBeforeCancelAck, a 1-master/1-worker cluster test that white-box busy-pollsPhysicalVertex#getExecutionState()right after issuingcancelJob(), kills the worker the instant any vertex is first observedCANCELING, and asserts the job still converges toCANCELED(not stuck) within a bounded time, and that the originalcancelJob()call also returns. - One-sentence summary: a genuinely well-researched, test-only regression PR whose every non-trivial claim about the engine's locking/state-machine behavior I independently verified against current
devsource, and which does not appear to introduce any flakiness of its own; I found no blocking issues.
1. Code Change Review
1.1 Core Logic Analysis
Single file changed: seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base/src/test/java/org/apache/seatunnel/engine/e2e/SplitClusterFaultToleranceIT.java (+243, new test method + 7 new private helpers, no production code touched, no existing test modified).
I traced the full runtime path the test is meant to exercise, verifying every step against current dev source rather than trusting the PR description:
test thread: clientJobProxy.cancelJob() (blocking: PassiveCompletableFuture#join(),
ClientJobProxy.java:141-145)
-> server: CoordinatorService#cancelJob(jobId) (CoordinatorService.java:1563-1584)
runs runningJobMaster.cancelJob() on executorService, future completes only
when that call returns
-> JobMaster#cancelJob -> SubPlan#cancelPipeline -> updatePipelineState(CANCELING)
-> SubPlan#stateProcess() case CANCELING (SubPlan.java:724-735):
coordinatorVertexList.forEach(task -> task.cancel()); // sequential!
physicalVertexList.forEach(task -> task.cancel()); // sequential!
-> PhysicalVertex#cancel() [synchronized] -> updateTaskState(CANCELING) [synchronized,
reentrant] :
this.currExecutionState = CANCELING; // volatile write, PhysicalVertex.java:396
stateProcess(); // reentrant, same lock
-> PhysicalVertex#stateProcess() case CANCELING -> noticeTaskExecutionServiceCancel()
(still holding the vertex's own monitor the whole time):
while (!taskFuture.isDone() && member still in cluster) {
invoke CancelTaskOperation on worker, .get() // real cross-process RPC
}
if (!taskFuture.isDone() && still CANCELING) {
updateTaskState(CANCELED); // <- the #10729 fallback this test targets
}
meanwhile, test thread busy-polls (Thread.yield(), no sleep):
getExecutionState() -> reads currExecutionState directly (volatile field read,
PhysicalVertex.java:482-483) -> NOT the distributed IMap, so this is a pure in-JVM
read with no network latency
the instant CANCELING is observed -> workerNode.shutdown()
Key Findings:
- The
currExecutionStatevolatile write happens strictly before the RPC is even sent, not just "before the ack arrives" as the PR description phrases it (PhysicalVertex.java:396 executes beforestateProcess()triggersnoticeTaskExecutionServiceCancel()'sinvoke()call). That makes the test's timing guarantee actually stronger than the PR body claims: the busy-poll thread can, in principle, observeCANCELINGand callshutdown()even before theCancelTaskOperationis dispatched, not merely before its ack returns. This is a good thing for reliability, just worth noting the PR's own reasoning slightly undersells its own robustness. SubPlan#stateProcess()'s CANCELING branch cancels vertices sequentially on a single thread, andPhysicalVertex#cancel()issynchronizedand blocks untilnoticeTaskExecutionServiceCancel()fully resolves (ack or fallback) before returning — I confirmed this directly (SubPlan.java:724-735, PhysicalVertex.java:409-465). This is exactly the property the test's Javadoc claims and depends on.- The mutual-exclusion argument for why
CoordinatorService#failedTaskOnMemberRemovedcannot be the mechanism that resolves this race also checks out:makeTasksFailed(CoordinatorService.java:2116-2138) does matchCANCELINGvertices on member loss and callsupdateStateByExecutionService(FAILED), but that funnels into the samesynchronized updateTaskState()(PhysicalVertex.java:351) as the cancel-thread, so it can only acquire the lock after the cancelling thread already resolved the vertex toCANCELED— andupdateTaskState's end-state consistency check (PhysicalVertex.java:376-380) then silently rejects the lateFAILEDtransition. This is a subtle, correct piece of concurrency archaeology; I verified it end-to-end rather than taking the PR body's word for it. ClientJobProxy#cancelJob()really does block synchronously (cancelFuture.join(), ClientJobProxy.java:145) whileCoordinatorService#cancelJobruns the whole per-vertex cancel on its own executor (CoordinatorService.java:1576-1582) — this is why the test correctly issuescancelJob()on its own thread (CompletableFuture.runAsync) rather than calling it inline, which would have deadlocked the test's own polling logic. Good catch by the author, not a cargo-culted pattern.- The white-box
getJobMaster(HazelcastInstanceImpl, long)technique (line 536-539) is not novel to this PR — it is line-for-line the same pattern already used in the siblingSplitClusterPendingJobLifecycleFailoverIT#getJobMaster(verified: identical body). Thepending_jobs_streaming_lifecycle.conffixture reused here is likewise a pre-existing file already consumed by that same sibling test, not a new/unvalidated fixture invented for this PR.
Runtime path summary for a reviewer who has not read the engine internals: the test relies on the fact that (a) CANCELING becomes visible to any thread the instant it is set, strictly before the cancel RPC is even sent, and (b) that RPC is a real cross-process/loopback socket call that cannot complete in zero time — so a tight busy-spin thread reacting to (a) is essentially guaranteed to land its workerNode.shutdown() no later than while the RPC to that same worker is in flight, exactly the window PR #10729 patched.
1.2 Compatibility Impact
Fully compatible. Test-only change, zero production code touched, adds a new @Test method plus private helpers to an existing E2E class; nothing else in the file is modified (confirmed via git diff dev...HEAD --stat: 243 insertions, 0 deletions, one file).
1.3 Performance / Side-Effect Analysis
awaitAnyVertexCancelingbusy-spins withThread.yield()for up to 10 seconds (line 503-522) instead of a polling/backoff wait. This is a deliberate, justified choice (the race window can be sub-millisecond, well under Awaitility's ~100ms default poll interval) and is bounded, so it cannot hang a CI run — it will just burn one core for up to 10s in the worst case (a hung/regressed build), and typically resolves in far less than that. Not a concern for a bounded E2E test.- No new production resources are held; the test cluster (1 master + 1 worker Hazelcast instance) and the
SeaTunnelClientare all shut down/closed in thefinallyblock, consistent with every other test in this class.
1.4 Error Handling and Logging
No formal issues found that block merge. Two non-blocking observations below (see Issue Summary and Section 5).
2. Code Quality Assessment
2.1 Coding Standards
New test method and every substantive private helper (assertAllVerticesRunning, awaitAnyVertexCanceling, getJobMaster, assertEventuallyCanceled) carry explanatory Javadoc that documents the "why" (race timing, synchronization guarantees, what regression is being guarded against), not just the "what" — this exceeds the project's usual bar for test helper documentation. assertRunningSubPlan, assertRunningVertex, isAnyVertexCanceling are trivial one-line delegates referenced directly from their documented caller and don't need their own Javadoc. No Thread.sleep-based waits, no @DisplayName usage, no stray System.out.println. Formatting matches the surrounding file's Google-Java-Format style.
2.2 Test Coverage and Test Stability
Rating: Stable, with one non-blocking coverage-fidelity caveat.
- No
Thread.sleepanywhere in the new code; all waits are either Awaitility (assertAllVerticesRunning,assertEventuallyCanceled) or the justified busy-spin discussed above. - Readiness signal before triggering the race is solid:
assertAllVerticesRunningwaits for the top-level job status and every coordinator/task vertex to individually reportRUNNING(not just the job-level status), so the cancel can't be confused with an in-flightDEPLOYING -> RUNNINGtransition (PhysicalVertex.java's ownstateProcess()DEPLOYING branch would otherwise make this ambiguous). - No shared static state, no unreleased resources (cluster/client all closed in
finally), no ordering dependency on other tests in the class (own dedicatedtestClusterName). - Non-blocking caveat (see Issue 1 below): the test has no positive assertion that the specific fallback branch in
noticeTaskExecutionServiceCancel(the one #10729 actually added) fired, as opposed to the vertex having already resolved via a normal successful ack just beforeworkerNode.shutdown()took effect. Given Finding 1 above (theCANCELINGwrite is visible even before the RPC is dispatched), this is very unlikely to happen in practice, and even if it did on some run, the test would not become flaky/red — it just wouldn't have exercised the exact line it's meant to guard in that particular run. Not a stability risk, just a coverage-fidelity nuance worth being aware of.
2.3 Documentation Updates
Not applicable — test-only change, no docs/en / docs/zh content is affected by this PR's scope.
3. Architectural Soundness
3.1 Elegance of the Solution
Precise fix (in this case, precise regression test). The trigger-construction technique (react to a volatile-field-visible state transition instead of guessing a sleep duration) is the correct way to deterministically hit a sub-millisecond race window, and is consistent with the same technique already used in the sibling SplitClusterPendingJobLifecycleFailoverIT/PR #12027, giving this a track record within the same test family rather than being a one-off invention.
3.2 Maintainability
High — the extensive Javadoc on the test method (lines 335-368) essentially inlines the concurrency analysis a future maintainer would otherwise have to redo from scratch to understand why the test is shaped this way, and explicitly documents why it asserts CANCELED and not FAILED.
3.3 Extensibility
The helpers (assertAllVerticesRunning, getJobMaster, awaitAnyVertexCanceling) are reasonably generic and could be reused by future engine-lifecycle E2E tests in this class without modification.
3.4 Historical-Version Compatibility
Not applicable in the usual sense (no serialization/state/checkpoint format touched), but I did specifically check that the referenced fix PR #10729 is merged to dev (confirmed: merged 2026-04-20) and that the fallback code path it added is present, unmodified in shape, in current dev (PhysicalVertex.java:458-464) — so the test targets real, currently-shipped behavior, not a hypothetical or already-superseded code path.
4. Issue Summary
| Number | Issue | Location | Severity |
|---|---|---|---|
| 1 | No positive assertion that the specific worker-crash fallback branch (vs. a normal fast successful ack) actually resolved the vertex; extremely unlikely to matter in practice given the volatile-write-before-RPC-dispatch ordering, but not provable by the test itself | SplitClusterFaultToleranceIT.java:415-465 (production code, referenced by the test's design) |
Low |
| 2 | awaitAnyVertexCanceling busy-spins on Thread.yield() for up to 10s in the worst case instead of a bounded-CPU wait strategy |
SplitClusterFaultToleranceIT.java:503-522 |
Low |
5. Merge Recommendation
Conclusion: Ready to merge
- Blockers — none.
- Recommended fixes — non-blocking:
- (Issue 1) If the author wants airtight proof the fallback branch specifically fired (not required for merge), a lightweight option would be a custom log4j2 appender or counter hook asserting the "cancel did not receive a terminal callback... mark task as CANCELED locally" log line (PhysicalVertex.java:459-461) was emitted during the test run — Option B below.
- (Issue 2) Could be left as-is; a bounded busy-spin in a test is a reasonable, well-precedented trade-off for a sub-millisecond race window and I would not hold up merge over it.
Overall assessment: this is one of the more carefully-researched E2E regression PRs I've reviewed in this batch — nearly every non-obvious claim about locking, volatile visibility, and call-chain ordering in the PR description is independently verifiable in current dev source, and I confirmed all of them by reading the actual PhysicalVertex, SubPlan, CoordinatorService, and ClientJobProxy code rather than trusting the write-up. CI ("Build") is still queued/pending as of this review (no result yet on either the apache-side pointer check or the fork's own Actions run) and there are no other reviews yet on this PR — please make sure CI comes back green before merging, but I see no code-side blocker.
Option A (accept as-is, recommended): merge once CI is green; the two Low-severity notes above are informational only.
Option B (only if the team wants stronger proof-of-coverage for this specific regression class going forward): add a log-assertion or a counter/hook in a follow-up PR to make the fallback-branch execution independently verifiable, applied consistently across this whole family of white-box race tests (#12027 and friends) rather than one-off in this PR.
|
CI status update on the same head reviewed above: at review time No change to the technical conclusion — this remains a test-only change with no code-side blocker from my side. With CI now green, the review above stands as Ready to merge. |
Adds a multi-node E2E test that reproduces the exact race fixed by PR failure", commit 2c81f7f): a task vertex could stay CANCELING forever if the worker executing it crashed after the cancel RPC was sent but before its ack arrived, since the pre-fix retry loop in PhysicalVertex#noticeTaskExecutionServiceCancel exited silently once the worker left the cluster, with nothing else driving the vertex to a terminal state. The test white-box polls PhysicalVertex#getExecutionState() in a tight loop right after issuing cancelJob(), shuts the worker down the instant a vertex is first observed CANCELING, and asserts the job converges to CANCELED within a bounded time instead of hanging.
f2c6c4c to
7cf39f6
Compare
DanielLeens
left a comment
There was a problem hiding this comment.
Thanks for pushing more coverage onto this PR, @davidzollo! I approved the original single-test version of this branch back on Sept 1, but the head has since moved from f2c6c4c to 7cf39f6 and this new commit adds a second, much larger regression test (testDeployNotDuplicatedWhenMasterKilledDuringDeploy, +~340 lines) alongside the original CANCELING test, without changing the commit message to mention it. Since real test logic changed, I re-traced the whole file top-to-bottom against current dev rather than reviewing only the delta, and I'm combining that into this single review.
What Problem Does This PR Solve?
This PR now adds two independent white-box E2E regression tests to SplitClusterFaultToleranceIT, each pinned to a specific, previously-unguarded Zeta engine race that was already fixed in dev but had no dedicated test:
testStreamJobCancelResolvesWhenWorkerCrashesBeforeCancelAck(the test reviewed on Sept 1): guards the fix in #10729 for a task vertex stayingCANCELINGforever if its worker crashes after the cancel RPC is sent but before the ack returns.testDeployNotDuplicatedWhenMasterKilledDuringDeploy(new in this commit): guards the fix in #10567 ("Make deployTask idempotent during master failover recovery") forTaskExecutionService#deployTaskthrowingRuntimeException("... already exists")when a new active master, restoring from failover, redeploys a vertex whose worker-side task is still genuinely alive.
One-sentence summary: both tests are well-researched, source-verified regression tests with no production code touched; I found no code-blocking issues, only one proportionality/CI-cost question on the new test's parallelism.
1. Code Change Review
1.1 Core Logic Analysis
Single file changed: seatunnel-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base/src/test/java/org/apache/seatunnel/engine/e2e/SplitClusterFaultToleranceIT.java (test-only, no src/main changes).
Test 1 — testStreamJobCancelResolvesWhenWorkerCrashesBeforeCancelAck (unchanged since my Sept 1 review). Runtime path, re-verified again against current dev:
ClientJobProxy.cancelJob() (blocking join)
-> CoordinatorService#cancelJob -> JobMaster#cancelJob -> SubPlan#updatePipelineState(CANCELING)
-> SubPlan#stateProcess() case CANCELING: coordinatorVertexList/physicalVertexList .forEach(task -> task.cancel()) [sequential]
-> PhysicalVertex#cancel() [synchronized] -> updateTaskState(CANCELING) -> stateProcess() [reentrant, same lock]
-> case CANCELING -> noticeTaskExecutionServiceCancel(): while (!taskFuture.isDone() && member still in cluster) invoke CancelTaskOperation, .get()
This still matches the described fix and the pre-fix silent-exit bug exactly as it did in the version I approved on Sept 1.
Test 2 — testDeployNotDuplicatedWhenMasterKilledDuringDeploy (new, SplitClusterFaultToleranceIT.java:1011-1499 plus helpers at :1517-1660). I independently verified every non-trivial claim in its javadoc against current dev source rather than trusting the PR description:
TaskExecutionService#deployTask(seatunnel-engine/seatunnel-engine-server/.../TaskExecutionService.java:445onward) does contain the exact idempotency guard the test targets:synchronized (this) { if (executionContexts.containsKey(taskGroup.getTaskGroupLocation())) { ...log a warning, release classloaders, return success... } }— confirming #10567 landed ondevand confirming what the pre-fix crash site looked like.PhysicalVertex#initStateFuture()(PhysicalVertex.java:182-203): for a persistedRUNNINGstate it callscheckTaskGroupIsExecutingand only downgrades toFAILINGon failure (never touches a confirmed-aliveRUNNING); for persistedDEPLOYINGit does the identical check-and-downgrade-only-on-failure — it never upgradesDEPLOYINGtoRUNNING. This exactly matches the javadoc's claim that a confirmed-aliveDEPLOYINGvertex staysDEPLOYINGafter restore.PhysicalVertex#stateProcess()(PhysicalVertex.java:581-596):case RUNNING: break;(true no-op) vscase DEPLOYING:unconditionally callingdeploy(...)again — this is the literal redeploy-on-restore branch the test is designed to hit.SubPlan#stateProcess()case DEPLOYING(SubPlan.java:702-718):physicalVertexList.forEach(task -> { if (CREATED) { task.startPhysicalVertex(); task.makeTaskGroupDeploy(); } })— a genuinely sequentialforEach, andPhysicalVertex#makeTaskGroupDeploy()(PhysicalVertex.java:303) callsupdateTaskState(DEPLOYING), which (per the synchronized/reentrantstateProcess()chain) runs the deploy RPC synchronously before returning — confirming the javadoc's claim that raising parallelism multiplies independent per-vertex windows rather than widening any single window.SubPlan#getPipelineRestoreNum()/pipelineRestoreNum(SubPlan.java:102,492,635) is incremented once perprepareRestorePipeline()call — the assertionsubPlan.getPipelineRestoreNum() <= 1inassertRecoveredWithBoundedPipelineRestore(:1560) is therefore a correct proxy for "no extra full-pipeline restart was forced by a failed redeploy."getJobMaster(:540-544),createTestResources(:200-202), andFaultToleranceFakeSourceAssertions.assertOutputRecoveredAndStableare pre-existing helpers in this same file, reused with matching signatures — no new production-adjacent test infrastructure was introduced, only new private helpers scoped to this one test (killActiveMasterWhileAnyVertexDeploying,isAnyVertexDeploying,assertRecoveredWithBoundedPipelineRestore,assertAllVertexRunning/assertVertexRunning,waitAndFindActiveMaster/findActiveMaster,awaitCoordinatorActive/isCoordinatorActive), none of which collide with any pre-existing method name in the class.- I confirmed #10567 is a real, merged PR (
gh pr view 10567: "[Fix][Zeta] Make deployTask idempotent during master failover recovery", merged 2026-03-15) with a title matching the javadoc's description precisely.
Both tests only reach the modified/guarded logic via a genuine failure-injection path (worker/master kill), not the normal happy path — that is expected and appropriate for a regression test, and is clearly disclosed in both javadocs rather than presented as a "normal path" fix.
1.2 Compatibility Impact
Fully compatible. No production code, no Option/config surface, no protocol/serialization format, and no public API touched. Purely additive test coverage in a src/test/java E2E file.
1.3 Performance / Side-Effect Analysis
No production runtime impact (test-only). Two side-effect observations on the new test specifically:
testDeployNotDuplicatedWhenMasterKilledDuringDeployusestestParallelism = 40(:1017), noticeably higher than every other test in this same file, which uses2or6(:90, :236, :578, :701, :841, :1135, :1284). The javadoc explains the rationale (more vertices = more independent per-vertex DEPLOYING windows for the watcher to land in, since a single vertex's own window does not widen), which is a legitimate trade-off, but 40 FakeSource+LocalFile task groups plus a 2-master/1-worker Hazelcast cluster in one JVM is meaningfully heavier than its siblings and worth keeping an eye on for flakiness/timeouts on constrained CI runners, especially since this IT module already runs several other multi-node cluster tests. Not a blocker, just a proportionality note — the class's default JUnit timeout budget is shared with sibling tests that use far lower parallelism, so this test alone shifts the module's resource profile.- The watcher (
killActiveMasterWhileAnyVertexDeploying,:1517-1539) tight-polls with a 1ms sleep for up to 30s on a dedicated single-thread executor; the polled read (jobMaster.getPhysicalPlan()+getExecutionState()) is a cheap in-JVM field access, so this is a bounded, test-only CPU cost and not a concern.
1.4 Error Handling and Logging
No swallowed exceptions of concern. killActiveMasterWhileAnyVertexDeploying declares throws InterruptedException, propagating it to the Future returned by masterKillExecutor.submit(...), which is correctly surfaced via deployingObserved.get(60, TimeUnit.SECONDS). The assertTrue(..., "Never observed any task vertex in DEPLOYING state ...") diagnostic message (:1057-1061) is a good practice: a missed race window fails with an actionable message instead of a bare timeout. masterKillExecutor.shutdownNow() runs unconditionally in the finally block (:1093), so no executor/thread leak even if an earlier assertion throws. No sensitive data is logged.
2. Code Quality Assessment
2.1 Coding Standards
Consistent with the file's existing style: same helper-method placement pattern (private static helpers near the bottom), same Awaitility-based polling idiom used elsewhere in the class, ASF header already present in the file (no new file created). No wildcard imports; the three new imports (SeaTunnelEngineException, ExecutorService, Executors, Future) are all used.
2.2 Test Coverage and Test Stability
Stability rating: Stable, with one moderate flakiness-risk factor to watch.
- No
Thread.sleep-as-synchronization anti-pattern: every wait either usesAwaitility.await()...untilAsserted(...)(:1039-1044,:1064-1075,:1560-1595,:1609-1622,:1636-1648) or a deliberately-tight, self-terminating poll loop with a clear deadline (:1517-1539). - No shared static mutable state between tests; each test builds its own cluster with a per-test-case cluster name, avoiding cross-test interference.
- No floating-point comparisons.
- Assertions are deterministic outcomes (state equality, bounded restore count, row count), not weak existence checks.
- Risk factor: as noted in 1.3,
testParallelism = 40combined with a 3-node in-process Hazelcast cluster is the heaviest test in this file by a wide margin; on a loaded/constrained CI runner this is the more plausible source of any future flakiness (timeout ondeployingObserved.get(60s)or on the 180sFINISHEDwait) than a logic bug in the test itself, given the runtime path was independently verified above. - Both new-in-this-PR tests are additive; no existing test was modified or weakened.
2.3 Documentation Updates
None needed — this is an internal E2E regression test with no user-facing behavior, config, or API change.
3. Architectural Soundness
3.1 Elegance of the Solution
Both tests build a deterministic trigger for a race window instead of gambling on sleep-based timing, and both explicitly design their assertions to hold on every legitimate outcome of the race (e.g., assertRecoveredWithBoundedPipelineRestore accepts either "worker already succeeded, no restore needed" or "exactly one clean restore", while treating anything beyond that as the regression). That is the same rigor as the test approved on Sept 1 and it's a strong pattern for white-box concurrency regression tests.
3.2 Maintainability
Both tests carry javadoc that documents the exact pre-fix bug, the referencing PR, the narrow trigger window, and why the assertions are written the way they are — a future maintainer changing PhysicalVertex/SubPlan state-machine internals has enough context here to understand what would break this test and why, without having to reverse-engineer the race from the assertions alone.
3.3 Extensibility
The new helpers (waitAndFindActiveMaster/findActiveMaster/awaitCoordinatorActive/isCoordinatorActive) generalize the existing single-purpose master-failover pattern already used elsewhere in this file (e.g. testStreamJobRestoreInMasterDown) into small reusable pieces scoped to this test; they don't touch or duplicate any existing helper.
3.4 Historical-Version Compatibility
No effect — test-only change, no serialization/checkpoint/state format touched, no config default changed. Both regression tests target behavior that is already the shipped, current behavior on dev (fixes #10729 and #10567 are both already merged); this PR only adds coverage that behavior doesn't regress.
4. Issue Summary
No blocking issues found. One non-blocking observation, not previously raised by any other reviewer (there have been none besides my earlier approval):
Issue 1 — Location: SplitClusterFaultToleranceIT.java:1017 (int testParallelism = 40;). Problem description: this new test's parallelism is 6-20x every sibling test in the same file. Potential risk: higher CPU/memory pressure and a larger surface for CI-runner-induced flakiness (not a logic risk) versus the rest of this IT class. Best improvement: consider whether a smaller parallelism (e.g. 15-20) still reliably reproduces the DEPLOYING window often enough in practice, to bring this test's resource footprint closer in line with its siblings — Option A: keep 40 if empirical CI runs show it's needed for reliability; Option B: lower it if a smaller value is equally reliable. Severity: Low. Raised by another reviewer: No.
5. Merge Recommendation
Both regression tests are technically sound, source-verified against current dev, additive-only, and consistent with this file's existing conventions. Live CI check (Build) is currently still pending on head 7cf39f6 at review time — per this review's own standard, that is not yet a completed/green result, so please confirm CI is green on this exact head before merging. mergeStateStatus currently shows BLOCKED, which in this repository's branch protection reflects "awaiting a maintainer review decision," not a merge conflict — compare/dev...head shows the branch is fully up to date with dev (ahead_by: 1, behind_by: 0).
Conclusion: Ready to merge after fixes
- None (no code-blocking issues).
Recommended fixes (non-blocking, optional):
- Consider whether
testParallelism = 40intestDeployNotDuplicatedWhenMasterKilledDuringDeploycan be reduced without losing reliability, to bring its CI resource footprint closer to its sibling tests (Issue 1). - Confirm the
BuildCI check completes green on the current head (7cf39f6) before merging, since it was still queued/pending at review time.
Nice work tightening this coverage further, and thanks for the very thorough javadocs on both tests — they make the "why" of each assertion easy to follow for whoever touches this state machine next.
DanielLeens
left a comment
There was a problem hiding this comment.
In my last review (this same head, 7cf39f6) I concluded "Ready to merge after fixes" with no code-blocking issues — the only items were an optional, non-blocking parallelism note (Issue 1) and confirming that the Build CI check, which was still queued/pending at review time, completed green.
I just re-checked: Build and all other checks on this head now report success, and the branch remains up to date with dev (no merge conflicts). Since CI was the only remaining item and it's now passing, I'm updating this to approve.
Thanks again for the very thorough regression coverage on both tests — happy to see this land.
Purpose
Adds multi-node E2E regression coverage for the CANCELING-stuck-forever race
fixed in #10729 ("[Fix][Zeta] prevent cancel stuck and downgrade tmp cleanup
failure", commit
2c81f7f3c31).Before that fix,
PhysicalVertex#noticeTaskExecutionServiceCancelsent aCancelTaskOperationto the worker owning the task and retried while thatworker remained a cluster member, but once the worker actually left the
cluster before acking the cancel, the retry loop simply exited without ever
resolving the task's state. The vertex — and therefore its pipeline and job
— stayed
CANCELINGforever, because nothing else in that method drove itto a terminal state. The fix added a fallback right after the retry loop: if
the loop exits with the ack still missing and the vertex is still
CANCELING, mark itCANCELEDlocally.The fix shipped with no dedicated regression test reproducing the original
multi-node timing/race at the engine level.
What was still missing
CoordinatorService#failedTaskOnMemberRemovedalso matchesCANCELINGtasks when a member is lost (this branch predates the fix — confirmed via
git showagainst the fix commit's parent), which raises the question ofwhether that path already covered the bug. It does not, reliably: it has to
go through the same
synchronized updateTaskStateasPhysicalVertex#cancel/#updateTaskState/#stateProcess, all of which aresynchronized on the vertex itself, and the whole call chain from
cancel()down into
noticeTaskExecutionServiceCancelruns on that lock withoutreleasing it. A competing
failedTaskOnMemberRemovedcall can thereforeonly run after the cancelling thread has already returned — by which
point the fixed code has already resolved the vertex to
CANCELED, and theend-state consistency check inside
updateTaskStaterejects any laterattempt to move a terminal-state task to
FAILED. So the fixed method's ownfallback is the sole, deterministic mechanism that unsticks this specific
race, which is why the new test asserts
CANCELED(notFAILED) as theoutcome.
I also checked the existing fault-tolerance suite
(
ClusterFaultToleranceIT,SplitClusterFaultToleranceIT,ClusterFailureNoRestoreIT) for anything that already combines a cancelrequest with a worker crash. It does not: existing tests either cancel a
job on a fully healthy cluster, or kill a worker on a job that is simply
RUNNINGwith no cancel in flight and cancel only after restore completes.None land a worker crash inside the narrow window between "cancel issued,
CANCELINGset" and "cancel ack received".What this test does
SplitClusterFaultToleranceIT#testStreamJobCancelResolvesWhenWorkerCrashesBeforeCancelAck:worker.
this suite (
pending_jobs_streaming_lifecycle.conf) and waits for thetop-level job status and every individual task vertex to report
RUNNING, so the cancel below isn't confounded by an in-flightDEPLOYINGtransition.cancelJob()on its own thread. This is required becauseCoordinatorService#cancelJobrunsJobMaster#cancelJobsynchronouslyon its own executor, and the client's
cancelJob()call blocks(
PassiveCompletableFuture#join) until that whole per-vertex cancelresolves — so the test thread needs to stay free to react while the
cancel is in flight on the server.
task vertex's
PhysicalVertex#getExecutionState()via the same in-JVMwhite-box access as
SplitClusterPendingJobLifecycleFailoverIT#getJobMaster,and the instant any vertex is first observed
CANCELING, immediatelyshuts the worker down.
CANCELEDwithin a bounded time (using analready-in-flight
waitForJobCompleteV2()future so the assertionitself cannot hang forever if the regression reappears), and that the
original
cancelJob()call also returns without hanging.Why this trigger-construction is reliable
The race window this bug depends on — between a vertex's state flipping to
CANCELINGand theCancelTaskOperationack coming back from the worker —can be sub-millisecond on a healthy local cluster, so blind timing (sleep
then kill) would be unreliable. Instead the test uses direct white-box
polling of internal engine state (same technique already proven in this
series, e.g. #12027), reacting the instant the state transition is
observed rather than guessing a delay. Because
SubPlan#cancelPipelinecancels vertices sequentially on a single thread and each vertex's cancel
call blocks synchronously on
noticeTaskExecutionServiceCancel, theCANCELINGstate is guaranteed to be visible for at least the duration ofa real cross-process Hazelcast operation invocation (these test nodes
communicate over real loopback sockets, not an in-memory bypass) — long
enough for a tight busy-poll loop to reliably observe it before the ack
round-trip completes.
Test plan
./mvnw spotless:applyrun on the affected module — no additionalformatting changes beyond what was already applied to the new code.
./mvnw install -DskipTestsrun on the affected module and itsdependency chain (this repo's shaded modules need
install, not barecompile/test-compile, to resolve relocated classes) — confirmedBUILD SUCCESS, and confirmed the new test class actually compiled(
target/test-classescontains the compiled.classfile for the newmethod) rather than relying on a build that skips test compilation
entirely.
injection) is left to CI per this repository's E2E conventions; not run
in this sandbox.