{"record":{"id":"51606bcbbc42b007","repo":"apache/dolphinscheduler","slug":"the-workflow-workflowexecution-getname-i-51606b","errorCode":null,"errorMessage":"\"The workflow \" + workflowExecution.getName() + \"is paused, shouldn't emit workflow finished event\"","messagePattern":"\"The workflow \" \\+ workflowExecution\\.getName\\(\\) \\+ \"is paused, shouldn't emit workflow finished event\"","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/workflow/statemachine/WorkflowPausedStateAction.java","lineNumber":114,"sourceCode":"\n    @Override\n    public void onFinalizeEvent(final IWorkflowExecution workflowExecution,\n                                final WorkflowFinalizeLifecycleEvent workflowFinalizeEvent) {\n        throwExceptionIfStateIsNotMatch(workflowExecution);\n        super.finalizeEventAction(workflowExecution);\n    }\n\n    @Override\n    public WorkflowExecutionStatus matchState() {\n        return WorkflowExecutionStatus.PAUSE;\n    }\n\n    /**\n     * The running state can only finish with success/failure.\n     */\n    @Override\n    protected void emitWorkflowFinishedEventIfApplicable(IWorkflowExecution workflowExecution) {\n        throw new IllegalStateException(\n                \"The workflow \" + workflowExecution.getName() +\n                        \"is paused, shouldn't emit workflow finished event\");\n    }\n}\n","sourceCodeStart":96,"sourceCodeEnd":119,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/workflow/statemachine/WorkflowPausedStateAction.java#L96-L119","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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.","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.","Upgrade to a recent DolphinScheduler release where pause/finish races in the workflow engine are fixed.","As a defensive pattern, always check workflowExecution.getState() == SUCCESS || FAILURE before invoking the finished-event hook."],"exampleFix":"// before\nworkflowEventBus.publish(WorkflowFinishedLifecycleEvent.of(workflowExecution)); // thrown if paused\n// after\nif (workflowExecution.getState() == WorkflowExecutionStatus.RUNNING_EXECUTION) {\n    workflowEventBus.publish(WorkflowFinishedLifecycleEvent.of(workflowExecution));\n}","handlingStrategy":"try-catch","validationCode":"if (workflowExecution.getState() == WorkflowExecutionStatus.RUNNING_EXECUTION) {\n    emitWorkflowFinishedEventIfApplicable(workflowExecution);\n}","typeGuard":"boolean canFinish(WorkflowExecution e) {\n    return e.getState() == WorkflowExecutionStatus.RUNNING_EXECUTION;\n}","tryCatchPattern":"try {\n    emitWorkflowFinishedEventIfApplicable(workflowExecution);\n} catch (IllegalStateException e) {\n    log.warn(\"Skipped finished event: {}\", e.getMessage());\n}","preventionTips":["Always gate finish-event emission on the execution being in RUNNING state","Serialize pause/stop commands against lifecycle events to avoid races","Treat this throw as a signal of a state-machine bug, not user error","Keep the master upgraded to releases with pause/finish race fixes"],"tags":["state-machine","workflow-engine","illegal-state","pause"],"backgroundTag":"invalid-state-transition","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}