apache/dolphinscheduler · error · IllegalStateException
"The workflow " + workflowExecution.getName() + "is failed,
Error message
"The workflow " + workflowExecution.getName() + "is failed, shouldn't emit workflow finished event"
What it means
WorkflowFailedStateAction forbids emitting a workflow finished event: a failed workflow should not additionally produce a 'finished' completion event. Hitting this throw means the state machine routed a finish event to the failed-state handler — an invariant violation.
Source
Thrown at dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/workflow/statemachine/WorkflowFailedStateAction.java:114
@Override
public void onFinalizeEvent(final IWorkflowExecution workflowExecution,
final WorkflowFinalizeLifecycleEvent workflowFinalizeEvent) {
throwExceptionIfStateIsNotMatch(workflowExecution);
super.finalizeEventAction(workflowExecution);
}
@Override
public WorkflowExecutionStatus matchState() {
return WorkflowExecutionStatus.FAILURE;
}
/**
* The running state can only finish with success/failure.
*/
@Override
protected void emitWorkflowFinishedEventIfApplicable(IWorkflowExecution workflowExecution) {
throw new IllegalStateException(
"The workflow " + workflowExecution.getName() +
"is failed, shouldn't emit workflow finished event");
}
}
View on GitHub (pinned to 02eac45a1b)
Solutions
- Trace the source of the duplicate WorkflowFinishedEvent
- Ensure events are de-duplicated/filtered by workflow execution id
- Verify failover logic doesn't re-emit finish events for already-failed workflows
- Upgrade to a version with idempotent event handling
Example fix
// before
workflowFinishedEventHandler.handle(event); // throws for FAILED workflows
// after
if (workflowExecution.getState() != WorkflowExecutionStatus.FAILURE) {
workflowFinishedEventHandler.handle(event);
} Defensive patterns
Strategy: validation
Validate before calling
if (workflowExecution.getState() == WorkflowExecutionStatus.FAILURE) { log.warn("skip finished event for failed workflow"); return; } Type guard
boolean canEmitFinished(IWorkflowExecution w) { return w.getState() != WorkflowExecutionStatus.FAILURE; } Try / catch
try { emitFinished(workflowExecution); } catch (IllegalStateException e) { log.warn("finished event rejected: {}", e.getMessage()); } Prevention
- Emit workflow finished events only once per execution
- Filter stale events for already-terminal workflows
- Make finish-event handling idempotent
When it happens
Trigger: emitWorkflowFinishedEventIfApplicable called on a workflow execution whose state is FAILED, e.g. duplicate WorkflowFinishedEvent delivery or wrong event routing.
Common situations: Event bus replay after failover, double fire of workflow-finished events, bugs in event-to-state-action dispatch.
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: " + workflowName + " state: " + actualState +
- "The workflow " + workflowExecution.getName() + "is success,
- 50004
- "The task: " + taskExecution.getName() + " state: " + taskIn
- "Cannot find TaskStateAction for state: " + taskExecutionSta
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/ead9e7b01828aa60.
Report an issue: GitHub.