apache/dolphinscheduler · error · IllegalStateException
"The workflow: " + workflowName + " state: " + actualState +
Error message
"The workflow: " + workflowName + " state: " + actualState + " is not match:" + expectState
What it means
Protected helper in AbstractWorkflowStateAction that verifies the workflow execution's current state matches the state handled by this state action subclass before performing an action. A mismatch means an event was routed to the wrong state handler — a state-machine invariant breach.
Source
Thrown at dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/workflow/statemachine/AbstractWorkflowStateAction.java:217
*/
protected abstract void emitWorkflowFinishedEventIfApplicable(final IWorkflowExecution workflowExecution);
protected boolean isWorkflowFinishable(final IWorkflowExecution workflowExecution) {
return workflowExecution.getWorkflowExecutionGraph().isAllTaskExecutionChainFinish();
}
/**
* Assert that the state of the task is the expected state.
*
* @throws IllegalStateException if the state of the task is not the expected state.
*/
protected void throwExceptionIfStateIsNotMatch(final IWorkflowExecution workflowExecution) {
checkNotNull(workflowExecution, "workflowExecution is null");
final WorkflowExecutionStatus actualState = workflowExecution.getState();
final WorkflowExecutionStatus expectState = matchState();
if (actualState != expectState) {
final String workflowName = workflowExecution.getName();
throw new IllegalStateException(
"The workflow: " + workflowName + " state: " + actualState + " is not match:" + expectState);
}
}
protected void logWarningIfCannotDoAction(final IWorkflowExecution workflowExecution,
final AbstractLifecycleEvent event) {
log.warn("Workflow {} state is {} cannot do action on event: {}",
workflowExecution.getName(),
workflowExecution.getState(),
event);
}
protected void finalizeEventAction(final IWorkflowExecution workflowExecution) {
log.info(WorkflowInstanceUtils.logWorkflowInstanceInDetails(workflowExecution));
workflowCacheRepository.remove(workflowExecution.getId());
workflowEventBusCoordinator.unRegisterWorkflowEventBus(workflowExecution);
workflowAlertManager.sendAlertWorkflowInstance(workflowExecution.getWorkflowInstance());View on GitHub (pinned to 02eac45a1b)
Solutions
- Log workflow name, actual and expected state to identify the racing event
- Check for duplicate/stale events in the execution event bus
- Verify master failover isn't replaying old events
- Retry or drop the event gracefully after confirming the workflow's actual state
Example fix
// before
stateAction.doAction(workflowExecution, event); // may throw on mismatch
// after
if (stateAction.matchState() == workflowExecution.getState()) {
stateAction.doAction(workflowExecution, event);
} else {
log.warn("Skipping event {} for {} in state {}", event, workflowExecution.getName(), workflowExecution.getState());
} Defensive patterns
Strategy: validation
Validate before calling
if (workflowExecution.getState() != expectedState) { log.warn("state mismatch: {} vs {}", workflowExecution.getState(), expectedState); return; } Try / catch
try { stateAction.doAction(workflowExecution, event); } catch (IllegalStateException e) { log.warn("stale event skipped: {}", e.getMessage()); } Prevention
- De-duplicate workflow events by execution id and state
- Drain/reconcile the event bus after failover
- Only dispatch events through the state-machine router matching current state
When it happens
Trigger: A workflow lifecycle event (e.g. task success/failure) delivered while the workflow execution is in a different state than the handler expects (e.g. a 'stop' event handled by RunningStateAction when the workflow already failed).
Common situations: Concurrent events racing during failover, duplicate events after master restart, event bus delivering stale events for already-finished workflows.
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 failed,
- "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/c2ae48480ecf750a.
Report an issue: GitHub.