[Fix-18624][Master] Make WorkflowSerialCoordinator restartable after HA failover - #18623
Merged
Merged
Conversation
…lover close() only set flag=false and left internalThread non-null, so the next start() threw "InternalThread is already started" and serial dispatch died silently. Mirror TaskGroupCoordinator.close(), which already does this. Add WorkflowSerialCoordinatorTest covering start -> close -> start, the case the existing TaskGroupCoordinatorTest does not exercise. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
yaodongen
requested review from
SbloodyS,
caishunfeng and
ruanwenjun
as code owners
September 8, 2026 11:25
|
Thanks for opening this pull request! Please check out our contributing guidelines. (https://github.com/apache/dolphinscheduler/blob/dev/docs/docs/en/contribute/join/pull-request.md) |
|
Awesome work, congrats on your first merged pull request! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Was this PR generated or assisted by AI?
YES — the diagnosis, the patch and this description were written with AI assistance (Claude). The root cause was confirmed against a live 3.4.2 cluster: the stack trace, the
starting.../started...mismatch and the recovery behaviour below are all taken from that cluster's logs, not inferred.Purpose of the pull request
Closes #18624.
WorkflowSerialCoordinatoris single-use, but the master restarts it on every HA transition. After anACTIVE -> STAND_BY -> ACTIVEflip within the same JVM,start()throws and serial dispatch dies silently —SERIAL_WAIT/SERIAL_DISCARD/SERIAL_PRIORITYworkflows then queue int_ds_serial_commandforever.close()leavesinternalThreadnon-null:while
start()refuses to run while it is set:and
MasterCoordinator.MasterCoordinatorListenercalls both against the same instance:The sibling
TaskGroupCoordinator.close(), invoked from that same listener, already interrupts the thread and nulls the field — which is why task groups survive a failover and serial dispatch does not. This PR makesWorkflowSerialCoordinator.close()match it.Two details make this silent rather than loud, and are the reason it is worth fixing rather than documenting:
AbstractHAServer.statusChangeassignsserverStatusbefore notifying listeners and swallows listener exceptions. The master therefore ends up reporting ACTIVE with a dead coordinator while still holding/nodes/master-coordinator, so no peer takes over and nothing self-heals.taskGroupCoordinator.start()runs first and succeeds, so the master keeps looking healthy.The only external symptom is a
WorkflowSerialCoordinator starting...log line with no matchingstarted....Observed on 3.4.2 (2 masters, JDBC registry): workflow instances stuck in
SERIAL_WAITfor 6h+, the oldest serial command waiting since 04:00 UTC,starting...logged twice againststarted...once:Affects every 3.4.x —
WorkflowSerialCoordinatorwas added in 3.4.0 by #17531 (DSIP-92) andclose()has not changed since; still present in 3.4.3 and ondev. Single-master deployments cannot hit it, becauseAbstractHAServeronly returns to ACTIVE from a REMOVE event carrying another server's identify, which cannot occur when one master is the sole writer of that path. That is presumably why it has gone unreported.Brief change log
WorkflowSerialCoordinator.close()now interruptsinternalThreadand sets it tonull, returns early when already closed, and issynchronizedto pair with the already-synchronizedstart()(internalThreadis notvolatile). Line-for-line mirror ofTaskGroupCoordinator.close().WorkflowSerialCoordinatorTestcoveringstart -> close -> start, plusstartwhile started and a repeatedclose.TaskGroupCoordinatorTest.start()covers onlystart -> close, which is why this asymmetry went unnoticed.Verify this pull request
Manually verified on a live 3.4.2 cluster:
ACTIVE -> STAND_BY -> ACTIVEflip and the exception above; serial dispatch stopped while the master still reported ACTIVE.internalThread == null(the state this patch restores on close) starts it cleanly and immediately drains the backlog:Built and tested locally on JDK 11 (one of the two CI targets;
pom.xmltargets source/target 1.8).Without the fix the new test reproduces the exact production failure — same exception, same line:
With the fix:
spotless:checkis bound to thecompilephase and was not skipped, so formatting is covered too.This change is backwards compatible and needs no entry in
docs/docs/en/guide/upgrade/incompatible.md.Pull Request Notice
Pull Request Notice