apache/dolphinscheduler · error · IllegalStateException
"The workflow: " + workflowExecution.getName() + " state is
Error message
"The workflow: " + workflowExecution.getName() + " state is " + workflowExecution.getState() + " can only finish with success/failed/stop but exist task chain which state is not success/failure/kill"
What it means
Thrown by the READY_STOP state action when a workflow in READY_STOP state is asked to emit a finished event but the task execution graph has chains whose state is not success/failure/kill. Stop semantics permit finishing only via success, failed, or kill; any other chain state makes a finished event invalid, so the engine throws this IllegalStateException.
Source
Thrown at dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/workflow/statemachine/WorkflowReadyStopStateAction.java:149
final IWorkflowExecutionGraph workflowExecutionGraph =
workflowExecution.getWorkflowExecuteContext().getWorkflowExecutionGraph();
final WorkflowEventBus workflowEventBus = workflowExecution.getWorkflowEventBus();
if (workflowExecutionGraph.isExistKilledTaskExecutionChain()) {
workflowEventBus.publish(WorkflowStoppedLifecycleEvent.of(workflowExecution));
return;
}
if (workflowExecutionGraph.isExistFailureTaskExecutionChain()) {
workflowEventBus.publish(WorkflowFailedLifecycleEvent.of(workflowExecution));
return;
}
if (workflowExecutionGraph.isAllTaskExecutionChainSuccess()) {
workflowEventBus.publish(WorkflowSucceedLifecycleEvent.of(workflowExecution));
return;
}
throw new IllegalStateException(
"The workflow: " + workflowExecution.getName() + " state is "
+ workflowExecution.getState()
+ " can only finish with success/failed/stop but exist task chain which state is not success/failure/kill");
}
}
View on GitHub (pinned to 02eac45a1b)
Solutions
- Find the offending task chain state in the workflow instance detail and manually kill or force-finish the stuck task.
- Re-issue a stop (kill) command so remaining chains transition to KILL, then let the workflow finish.
- Check master logs for kill-timeout or worker-unreachable errors; ensure workers are healthy and reachable.
- Upgrade the master if stop/kill races repeatedly leave chains non-terminal; report as a bug if stock code hits this.
Example fix
// before
throw new IllegalStateException("... exist task chain which state is not success/failure/kill");
// after
if (workflowExecutionGraph.isAllTaskExecutionChainFinished()) {
workflowEventBus.publish(WorkflowStopLifecycleEvent.of(workflowExecution));
return;
}
throw new IllegalStateException("... exist task chain which state is not success/failure/kill"); Defensive patterns
Strategy: try-catch
Validate before calling
if (workflowExecutionGraph.isAllTaskExecutionChainSuccess()
|| workflowExecutionGraph.isAllTaskExecutionChainFailed()
|| workflowExecutionGraph.isAllTaskExecutionChainKill()) {
emitWorkflowFinishedEventIfApplicable(workflowExecution);
} Try / catch
try {
emitWorkflowFinishedEventIfApplicable(workflowExecution);
} catch (IllegalStateException e) {
log.error("Workflow {} cannot finish from stop: {}", workflowExecution.getName(), e.getMessage());
// re-issue kill for chains not in KILL state
} Prevention
- Verify workers ACK kill requests so chains reach KILL state
- Keep workers reachable; failover can leave chains in DISPATCH
- Avoid racing stop with pause/complete on the same execution
- Re-issue stop (kill) if the workflow stays in READY_STOP
When it happens
Trigger: onStartEvent -> emitWorkflowFinishedEventIfApplicable while workflow state is READY_STOP and not all task chains are success, with at least one chain in a state other than failed or kill (e.g. still running after the stop request, in dispatch, or paused).
Common situations: A stop command raced with task completion or with a pause command; workers failed to ACK the kill so chains never reached KILL; failover left chains in DISPATCH; custom event handling bypassing normal stop flow.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- "The workflow " + workflowExecution.getName() + "is paused,
- "The workflow: " + workflowExecution.getName() + " state is
- "The task: " + taskName + " state: " + actualState + " is no
- The workflow instance: %s status is %s, can not stop
- WorkflowInstance: %s stop failed: %s
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/c49f192691d2a3e1.
Report an issue: GitHub.