apache/dolphinscheduler · error · IllegalStateException

"The workflow " + workflowExecution.getName() + "is paused,

Error message

"The workflow " + workflowExecution.getName() + "is paused, shouldn't emit workflow finished event"

What it means

The master workflow engine throws this IllegalStateException when the workflow-execution state machine is asked to emit a 'workflow finished' lifecycle event while the workflow is in the PAUSED state. A paused workflow cannot finish, so emitting a finished event would be an invalid state transition; the engine deliberately fails fast to protect the lifecycle invariant that only RUNNING workflows transitioning to success/failure can finish.

Source

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

    @Override
    public void onFinalizeEvent(final IWorkflowExecution workflowExecution,
                                final WorkflowFinalizeLifecycleEvent workflowFinalizeEvent) {
        throwExceptionIfStateIsNotMatch(workflowExecution);
        super.finalizeEventAction(workflowExecution);
    }

    @Override
    public WorkflowExecutionStatus matchState() {
        return WorkflowExecutionStatus.PAUSE;
    }

    /**
     * The running state can only finish with success/failure.
     */
    @Override
    protected void emitWorkflowFinishedEventIfApplicable(IWorkflowExecution workflowExecution) {
        throw new IllegalStateException(
                "The workflow " + workflowExecution.getName() +
                        "is paused, shouldn't emit workflow finished event");
    }
}

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Inspect the workflow execution's event log to see whether a PAUSE command raced with the final task completion; if so, resume the workflow and let it finish, or kill it.
  2. Verify the master's state machine code was not customized; in stock code this path is unreachable, so treat it as an engine bug and report it with master logs.
  3. Upgrade to a recent DolphinScheduler release where pause/finish races in the workflow engine are fixed.
  4. As a defensive pattern, always check workflowExecution.getState() == SUCCESS || FAILURE before invoking the finished-event hook.

Example fix

// before
workflowEventBus.publish(WorkflowFinishedLifecycleEvent.of(workflowExecution)); // thrown if paused
// after
if (workflowExecution.getState() == WorkflowExecutionStatus.RUNNING_EXECUTION) {
    workflowEventBus.publish(WorkflowFinishedLifecycleEvent.of(workflowExecution));
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (workflowExecution.getState() == WorkflowExecutionStatus.RUNNING_EXECUTION) {
    emitWorkflowFinishedEventIfApplicable(workflowExecution);
}

Type guard

boolean canFinish(WorkflowExecution e) {
    return e.getState() == WorkflowExecutionStatus.RUNNING_EXECUTION;
}

Try / catch

try {
    emitWorkflowFinishedEventIfApplicable(workflowExecution);
} catch (IllegalStateException e) {
    log.warn("Skipped finished event: {}", e.getMessage());
}

Prevention

When it happens

Trigger: Calling emitWorkflowFinishedEventIfApplicable() on a workflowExecution whose state is WorkflowExecutionStatus.PAUSED — i.e. the paused-state action's post-transition hook runs against an execution that did not actually move to a terminal state (success/failure) before finish-event emission was attempted.

Common situations: Usually an engine bug or a race: a pause command arrived concurrently with completion of the last task, or custom/patched state-machine code calls the finish-event hook on a paused execution without first checking the state. End users rarely cause this directly.

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/51606bcbbc42b007. Report an issue: GitHub.