apache/dolphinscheduler · error · IllegalStateException

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

Error message

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

What it means

WorkflowFailoverStateAction also forbids emitting a workflow finished event (message text says 'is success' but the class is failover): a failover-state workflow must transition rather than emit a terminal finished event. Thrown when a finish event reaches this handler.

Source

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

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

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

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

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Confirm the workflow instance's state at the time of the event (DB check)
  2. Filter/de-duplicate finish events after failover recovery
  3. Ensure failover completes state transition before processing further events
  4. Upgrade to a release with failover event idempotency fixes

Example fix

// before
stateAction.emitWorkflowFinishedEventIfApplicable(execution); // throws in FAILOVER
// after
if (execution.getState() == WorkflowExecutionStatus.RUNNING_EXECUTION) {
    stateAction.emitWorkflowFinishedEventIfApplicable(execution);
}
Defensive patterns

Strategy: validation

Validate before calling

if (workflowExecution.getState() == WorkflowExecutionStatus.FAILOVER) { log.warn("finish event during failover, ignore"); return; }

Type guard

boolean canEmitFinished(IWorkflowExecution w) { return w.getState() != WorkflowExecutionStatus.FAILOVER; }

Try / catch

try { emitFinished(workflowExecution); } catch (IllegalStateException e) { log.warn("event rejected in failover state: {}", e.getMessage()); }

Prevention

When it happens

Trigger: emitWorkflowFinishedEventIfApplicable invoked on a workflow execution in FAILOVER state — a routed WorkflowFinishedEvent that should instead have triggered failover logic.

Common situations: Stale finish events surviving a master failover, event replay, incorrect state-action lookup during the failover window.

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