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/paused but exist task chain which state is not success/failure/pause"

What it means

Thrown by the READY_PAUSE state action when the workflow is finishing from a ready-to-pause state but the task execution graph does not support any legal terminal outcome. The engine only allows a ready-paused workflow to end as success, failed, or paused; if some task chain is still in a state outside success/failure/pause, no finished event can be validly published, so the invariant is enforced by throwing.

Source

Thrown at dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/workflow/statemachine/WorkflowReadyPauseStateAction.java:148

        }
        final IWorkflowExecutionGraph workflowExecutionGraph = workflowExecution.getWorkflowExecutionGraph();
        final WorkflowEventBus workflowEventBus = workflowExecution.getWorkflowEventBus();
        if (workflowExecutionGraph.isExistPausedTaskExecutionChain()) {
            workflowEventBus.publish(WorkflowPausedLifecycleEvent.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/paused but exist task chain which state is not success/failure/pause");
    }
}

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Check the task instance states in the UI/DB to find which chain is in an unexpected state and resolve it (retry, kill, or force-success the task).
  2. Restart/resume the workflow so remaining chains reach a terminal state before finishing.
  3. Check master logs for failover or worker-disconnect events that left chains non-terminal; upgrade the master if this recurs.
  4. If reproducible with stock code, file a bug with the workflow execution graph dump — this branch indicates a state-machine invariant bug.

Example fix

// before
throw new IllegalStateException("... exist task chain which state is not success/failure/pause");
// after
if (workflowExecutionGraph.isAllTaskExecutionChainFinished()) {
    workflowEventBus.publish(WorkflowPauseLifecycleEvent.of(workflowExecution));
    return;
}
throw new IllegalStateException("... exist task chain which state is not success/failure/pause");
Defensive patterns

Strategy: try-catch

Validate before calling

if (workflowExecutionGraph.isAllTaskExecutionChainSuccess()
        || workflowExecutionGraph.isAllTaskExecutionChainFailed()
        || workflowExecutionGraph.isAllTaskExecutionChainPause()) {
    emitWorkflowFinishedEventIfApplicable(workflowExecution);
}

Try / catch

try {
    emitWorkflowFinishedEventIfApplicable(workflowExecution);
} catch (IllegalStateException e) {
    log.error("Workflow {} cannot finish from pause: {}", workflowExecution.getName(), e.getMessage());
    // inspect remaining task chains and resolve stuck task
}

Prevention

When it happens

Trigger: onStartEvent -> emitWorkflowFinishedEventIfApplicable while workflow state is READY_PAUSE and workflowExecutionGraph.isAllTaskExecutionChainSuccess() is false, yet no task chain reached failed/pause either (e.g. a chain stuck in a non-terminal or unexpected state such as DISPATCH or a killed task when pause semantics expect pause/failed).

Common situations: Worker failures or task-kill timeouts leaving task chains in states the pause path does not expect; engine bugs in failover; running a modified/older master where pause handling of killed tasks differs; concurrent stop+pause commands.

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


AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06). Data as JSON: /api/errors/11b0bc6d752617a6. Report an issue: GitHub.