{"record":{"id":"a738b796f6d4069a","repo":"apache/dolphinscheduler","slug":"the-workflow-workflowexecution-getname-i-a738b7","errorCode":null,"errorMessage":"\"The workflow \" + workflowExecution.getName() + \"is success, shouldn't emit workflow finished event\"","messagePattern":"\"The workflow \" \\+ workflowExecution\\.getName\\(\\) \\+ \"is success, 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/WorkflowFailoverStateAction.java","lineNumber":117,"sourceCode":"\n    @Override\n    public void onFinalizeEvent(final IWorkflowExecution workflowExecution,\n                                final WorkflowFinalizeLifecycleEvent workflowFinalizeEvent) {\n        throwExceptionIfStateIsNotMatch(workflowExecution);\n        logWarningIfCannotDoAction(workflowExecution, workflowFinalizeEvent);\n    }\n\n    @Override\n    public WorkflowExecutionStatus matchState() {\n        return WorkflowExecutionStatus.FAILOVER;\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 success, shouldn't emit workflow finished event\");\n    }\n}\n","sourceCodeStart":99,"sourceCodeEnd":122,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/workflow/statemachine/WorkflowFailoverStateAction.java#L99-L122","documentation":"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.","triggerScenarios":"emitWorkflowFinishedEventIfApplicable invoked on a workflow execution in FAILOVER state — a routed WorkflowFinishedEvent that should instead have triggered failover logic.","commonSituations":"Stale finish events surviving a master failover, event replay, incorrect state-action lookup during the failover window.","solutions":["Confirm the workflow instance's state at the time of the event (DB check)","Filter/de-duplicate finish events after failover recovery","Ensure failover completes state transition before processing further events","Upgrade to a release with failover event idempotency fixes"],"exampleFix":"// before\nstateAction.emitWorkflowFinishedEventIfApplicable(execution); // throws in FAILOVER\n// after\nif (execution.getState() == WorkflowExecutionStatus.RUNNING_EXECUTION) {\n    stateAction.emitWorkflowFinishedEventIfApplicable(execution);\n}","handlingStrategy":"validation","validationCode":"if (workflowExecution.getState() == WorkflowExecutionStatus.FAILOVER) { log.warn(\"finish event during failover, ignore\"); return; }","typeGuard":"boolean canEmitFinished(IWorkflowExecution w) { return w.getState() != WorkflowExecutionStatus.FAILOVER; }","tryCatchPattern":"try { emitFinished(workflowExecution); } catch (IllegalStateException e) { log.warn(\"event rejected in failover state: {}\", e.getMessage()); }","preventionTips":["Complete failover transitions before processing further events","Suppress finish events recorded before failover began","Keep failover event replay logic idempotent"],"tags":["java","state-machine","workflow"],"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"}