Repository navigation
Description
Search before asking
- I had searched in the issues and found no similar issues.
What happened
Describe the bug
After #18406 (fixed by #18415 in 3.4.3), an architectural gap remains: the "persist task failure to DB" step and the "advance the workflow" step are two non-atomic operations. If the master crashes / restarts / fails over between them, the DB is left with task = FAILURE while workflow = RUNNING. The serial lock (t_ds_serial_command) is not released, so subsequent serial schedules of the same workflow can never trigger.
#18406 only fixes one specific DAG shape (Continue failure strategy + a blocked intermediate predecessor). It does not provide any independent reconciliation for the serial lock.
Which version of DolphinScheduler
3.4.2 (observed); 3.4.3 partially fixed (#18406/#18415). The non-atomicity and the missing serial-lock reconciliation are NOT fixed in 3.4.3.
To Reproduce
- Use a workflow whose task can fail.
- Make the master crash/restart/failover in the window between the task-failure write to DB and the workflow-advance steps (or otherwise get the workflow stuck while a task is FAILURE).
- Observe:
t_ds_task_instance.state = FAILURE,t_ds_workflow_instance.state = RUNNING_EXECUTION, and a stale row remains int_ds_serial_command. - Subsequent serial schedules of the same workflow never trigger.
Root cause
In AbstractTaskStateAction.onFailedEvent():
releaseTaskInstanceResourcesIfNeeded(taskExecution);
persistentTaskInstanceFailedEventToDB(taskExecution, ...); // (1) persisted to DB
...
graph.markTaskExecutionChainFailure(taskExecution); // (2) in-memory only
publishWorkflowInstanceTopologyLogicalTransitionEvent(...); // (3) in-memory onlypersistentTaskInstanceFailedEventToDB is a bare taskInstanceDao.updateById(...) with no @Transactional. Steps (2) and (3) live only in master memory. If the master dies after (1) but before (2)/(3) complete, steps (2)/(3) vanish with the memory, leaving task = FAILURE, workflow = RUNNING in the DB.
On failover, the graph is rebuilt from the DB, but the failed task is not reliably re-marked into a failure chain and the workflow terminal event is not triggered — emitWorkflowFinishedEventIfApplicable returns early when !isWorkflowFinishable. The workflow stays RUNNING.
Additionally, WorkflowSerialCoordinator.doStart() (lines 93–109) only handles SERIAL_WAIT / DISCARD / PRIORITY. There is no logic to scan terminal/zombie workflows and recycle their stale t_ds_serial_command rows. Serial-lock cleanup depends 100% on workflowFinish being reached.
Proposed improvement
Add a reconciliation task to WorkflowSerialCoordinator that scans already-terminal / zombie workflows and recycles their residual t_ds_serial_command rows. This is complementary to the #18406 fix (which only covers the Continue + blocked-predecessor shape).
Additional context
- [Bug] Task instance failed but workflow instance remains in RUNNING state #18406 / [Fix-18406] Fix task instance failed but workflow instance remains in running state while using continue strategy with a blocked intermediate predecessor #18415 fixed the Continue + blocked-predecessor case only.
- The 3.4.3 fix is verifiable in
AbstractWorkflowStateAction.tryToTriggerSuccessorsAfterTaskFinish(adds anisAllTaskExecutionChainFinishOR-condition), but it does not address the non-atomic write or the serial-lock reconciliation.
What you expected to happen
Once a task is persisted as FAILURE, the workflow should reliably advance
to its terminal state (FAILURE), and its serial lock (t_ds_serial_command)
should be released. Even if the master crashes or fails over in between,
the failover rebuild should recognize the already-failed task, drive the
workflow to a terminal state, and clean up the stale serial command.
Persisting the task failure and advancing the workflow are two separate,
non-atomic steps in AbstractTaskStateAction.onFailedEvent():
1. persistentTaskInstanceFailedEventToDB() -> bare updateById, no
@Transactional, written to DB immediately
2. markTaskExecutionChainFailure() -> in-memory only
3. publishWorkflowInstanceTopologyLogicalTransitionEvent() -> in-memory only
Steps 2 and 3 live only in master memory. If the master crashes/restarts/
fails over after step 1 but before 2-3 finish, steps 2-3 are lost with the
memory, leaving task = FAILURE but workflow = RUNNING in the DB.
Failover rebuilds the graph from the DB but does not reliably re-mark the
failed task into a failure chain or trigger the workflow terminal event
(emitWorkflowFinishedEventIfApplicable returns early when the workflow is
not "finishable"), so the workflow stays RUNNING.
Separately, the serial lock has no independent reconciliation:
WorkflowSerialCoordinator.doStart() only handles SERIAL_WAIT / DISCARD /
PRIORITY and never scans terminal/zombie workflows to recycle their stale
t_ds_serial_command rows. So serial-lock cleanup depends entirely on
workflowFinish being reached, which never happens here.
This is the gap NOT covered by #18406 / #18415 (which only fixed the
Continue + blocked-predecessor DAG shape).
How to reproduce
This is a crash-window / failover defect, so it is best shown by observing
the inconsistent state directly, plus an optional fault-injection trigger.
Path 1 — observe the inconsistent state directly (reliable)
-
Query for workflows whose task has failed but whose workflow instance is
still RUNNING. In DolphinScheduler 3.4.x:-- task_state / wf_state enum values: verify against TaskExecutionStatus
-- and WorkflowExecutionStatus; the query below filters on
-- task = FAILURE and workflow = RUNNING_EXECUTION
SELECT w.id, w.name, w.state AS wf_state, t.state AS task_state
FROM t_ds_workflow_instance w
JOIN t_ds_task_instance t ON t.workflow_instance_id = w.id
WHERE w.state = /* RUNNING_EXECUTION /
AND t.state = / FAILURE */; -
For those workflow ids, a stale serial command remains:
SELECT * FROM t_ds_serial_command
WHERE workflow_instance_id IN (<ids from step 1>); -
Trigger the same workflow again with serial scheduling: the next run
never starts because the stale serial lock is never released.
Path 2 — fault injection (best effort, window is hard to hit)
- Deploy 3.4.2 and configure a workflow with a task that fails, with serial
scheduling enabled. - Immediately after the task failure is written to the DB but before the
workflow advances, force-kill the master (or trigger a failover).
The window between "persist task failure" and "advance workflow" is
small, so this may take several attempts. - Restart the master / let failover rebuild the graph from the DB.
- Observe: t_ds_task_instance.state = FAILURE,
t_ds_workflow_instance.state = RUNNING_EXECUTION, and the
t_ds_serial_command row is never cleaned up.
Anything else
No response
Version
3.4.2
Are you willing to submit PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct
Activity
SbloodyS commentedon Oct 13, 2026
Based on the 3.4.3 source, this report does not yet establish a separate crash/failover bug. Although persisting the task failure and advancing the in-memory graph are separate operations, recovery includes an event replay path: WorkflowFailoverCommandHandler rebuilds the graph using existing task instances, and TaskFailureStateAction.onStartEvent() republishes TaskFailedLifecycleEvent for a task already in FAILURE. That event re-enters the failure-chain marking and topology transition logic. Additionally, workflowFinish() updates the workflow state and deletes its serial command within the same transaction.
A FAILURE task belonging to a RUNNING_EXECUTION workflow is also insufficient evidence by itself: the task may be awaiting retry, or other branches may still be executing under the Continue failure strategy. The absence of an independent serial-command reconciliation mechanism is a potential resilience improvement, but it does not demonstrate that the existing failover recovery path fails.
To confirm this as a bug, please provide:
The key missing evidence is where the recovered execution stops progressing despite the failure-event replay path. That would help distinguish a recovery defect from the previously reported DAG issue or an expected intermediate state.
sql-wj commentedon Oct 13, 2026
Describe the bug
After #18406 (fixed by #18415 in 3.4.3), an architectural gap remains: the "persist task failure to DB" step and the "advance the workflow" step are two non-atomic operations. If the master crashes / restarts / fails over between them, the DB is left with
task = FAILUREwhileworkflow = RUNNING. The serial lock (t_ds_serial_command) is not released, so subsequent serial schedules of the same workflow can never trigger.#18406 only fixes one specific DAG shape (Continue failure strategy + a blocked intermediate predecessor). It does not provide any independent reconciliation for the serial lock.
Which version of DolphinScheduler
3.4.2 (observed); 3.4.3 partially fixed (#18406/#18415). The non-atomicity and the missing serial-lock reconciliation are NOT fixed in 3.4.3.
To Reproduce
t_ds_task_instance.state = FAILURE,t_ds_workflow_instance.state = RUNNING_EXECUTION, and a stale row remains int_ds_serial_command.Root cause
In
AbstractTaskStateAction.onFailedEvent():persistentTaskInstanceFailedEventToDBis a baretaskInstanceDao.updateById(...)with no@Transactional. Steps (2) and (3) live only in master memory. If the master dies after (1) but before (2)/(3) complete, steps (2)/(3) vanish with the memory, leavingtask = FAILURE, workflow = RUNNINGin the DB.On failover, the graph is rebuilt from the DB, but the failed task is not reliably re-marked into a failure chain and the workflow terminal event is not triggered —
emitWorkflowFinishedEventIfApplicablereturns early when!isWorkflowFinishable. The workflow stays RUNNING.Additionally,
WorkflowSerialCoordinator.doStart()(lines 93–109) only handlesSERIAL_WAIT/DISCARD/PRIORITY. There is no logic to scan terminal/zombie workflows and recycle their stalet_ds_serial_commandrows. Serial-lock cleanup depends 100% onworkflowFinishbeing reached.Proposed improvement
Add a reconciliation task to
WorkflowSerialCoordinatorthat scans already-terminal / zombie workflows and recycles their residualt_ds_serial_commandrows. This is complementary to the #18406 fix (which only covers the Continue + blocked-predecessor shape).SbloodyS commentedon Oct 15, 2026
Based on the 3.4.3 source, this report does not yet establish a separate crash/failover bug.
[Source evidence] Although persisting task failure and advancing the in-memory graph are separate operations, recovery includes event replay.
WorkflowFailoverCommandHandlerrebuilds the execution graph using existing task instances, andTaskFailureStateAction.onStartEvent()republishesTaskFailedLifecycleEventfor a task already inFAILURE. This re-enters the retry, failure-chain marking, and topology-transition logic. Additionally,workflowFinish()updates the workflow state and deletes its serial command within the same transaction.[Assessment] A
FAILUREtask within aRUNNING_EXECUTIONworkflow is insufficient evidence of a stuck workflow: the task may be awaiting retry, or other branches may still be running under the Continue failure strategy. Independent serial-command reconciliation could be a resilience improvement, but its absence alone does not demonstrate that recovery fails.To confirm the bug, please provide a minimal reproduction on 3.4.3, including the DAG, failure strategy, retry settings, serial execution mode, exact crash injection point, and Master logs covering failover and recovered execution. Timestamped database records should show that the workflow remains stuck after retries and other branches have finished, with a subsequent serial instance still blocked.
The key missing evidence is where recovery stops progressing despite the failure-event replay path.
ruanwenjun commentedon Oct 16, 2026
@sql-wj Are you saying there's a bug in the fault-tolerant process? Can you write a test method that can be reproduced?
kittimzhe commentedon Oct 16, 2026
Opening the consensus question @SbloodyS asked for before #18709 can come back.
Where we agree (per your source evidence): crash recovery replays events —
WorkflowFailoverCommandHandlerrebuilds the graph from existing task instances, so a master dying between "persist task failure" and "advance the workflow" does not corrupt the workflow side. #18709 does not dispute that, and never needed to.The residue the PR targets is narrower: rows in
t_ds_serial_commandwhose instance is terminal, missing, or has a null id. Normal cleanup is same-transaction with workflow finish, and the trigger path persists state before inserting the row in the same transaction — so a stale row is not produced by the crash-between-two-writes window. What remains is defense-in-depth for rows that are already stale when read (upgrades from older deployments, rows orphaned by operational restores, or paths neither of us has enumerated).The consensus question is about shape, not necessity of the fix. Three candidates:
My preference is 1, with the null-id and missing-instance cases only (terminal-state deletion is the part that could disagree with a legitimate pause/stop race, and #18709's tests pin that distinction). But if maintainers see the table as strictly derived-and-rebuildable, 3 is defensible and #18709 stays closed.
Which shape do we want? Once that's settled, #18709 (or its replacement) comes back matching it.
github-actions commentedon Nov 16, 2026
This issue has been automatically marked as stale because it has not had recent activity for 30 days. It will be closed in next 7 days if no further activity occurs.
github-actions commentedon Nov 24, 2026
This issue has been closed because it has not received response for too long time. You could reopen it if you encountered similar problems in the future.
kittimzhe commentedon Nov 26, 2026
Following up on the consensus question I posted on Oct 16 — the issue was auto-closed by the stale bot before anyone could weigh in, so summarizing where things stand.
Since then, two related fixes landed:
workflowFinishnow leaves the shared instance untouched until the finish transaction commits, so a rollback keeps the finish event retryable. This closes the strongest residue path I had in mind (instance already terminal + serial row not deleted).I re-checked current
dev:WorkflowSerialCoordinatorstill performs no instance-state check when polling, so a row whose instance is terminal, missing, or has a null id would still be handed to a handler. That said, from reading current dev I no longer see a code path that marks the instance terminal outside the finish transaction, so the strongest residue path appears closed — what remains is operational (upgrades from older deployments, restores, manual DB edits).So the question narrows to: is this considered done (issue stays closed, matching shape 3 — no runtime change), or should #18709 come back narrowed (read-time reconciliation limited to missing/null-id rows, without terminal-state deletion)? Happy either way — just don't want the question lost to the stale bot.
@SbloodyS @ruanwenjun
ruanwenjun commentedon Nov 26, 2026
@kittimzhe I've reopened this issue, but I'm still not entirely sure what the current problem is. Are you saying that some incompatible data—whether caused by manual operations in the database or due to past upgrades—has never been cleared, resulting in data that is out of sync? If that's the case, we shouldn't consider addressing it for now.