{"record":{"id":"2d6b8844072fdd6a","repo":"apache/dolphinscheduler","slug":"the-workflow-instance-s-status-is-s-can-not-st","errorCode":null,"errorMessage":"The workflow instance: %s status is %s, can not stop","messagePattern":"The workflow instance: (.+?) status is (.+?), can not stop","errorType":"exception","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/executor/workflow/StopWorkflowInstanceExecutorDelegate.java","lineNumber":70,"sourceCode":"    @Override\n    public Void execute(StopWorkflowInstanceOperation workflowInstanceControlRequest) {\n        final WorkflowInstance workflowInstance = workflowInstanceControlRequest.workflowInstance;\n        exceptionIfWorkflowInstanceCannotStop(workflowInstance);\n\n        if (workflowInstance.getState().isCanDirectStopInDB()) {\n            directStopInDB(workflowInstance);\n        } else {\n            stopInMaster(workflowInstance);\n        }\n        return null;\n    }\n\n    void exceptionIfWorkflowInstanceCannotStop(WorkflowInstance workflowInstance) {\n        final WorkflowExecutionStatus workflowInstanceState = workflowInstance.getState();\n        if (workflowInstanceState.isCanStop()) {\n            return;\n        }\n        throw new ServiceException(\n                \"The workflow instance: \" + workflowInstance.getName() + \" status is \" + workflowInstanceState\n                        + \", can not stop\");\n    }\n\n    void directStopInDB(WorkflowInstance workflowInstance) {\n        // todo: move the stop logic to master\n        transactionTemplate.execute(status -> {\n            workflowInstanceDao.updateWorkflowInstanceState(\n                    workflowInstance.getId(),\n                    workflowInstance.getState(),\n                    WorkflowExecutionStatus.STOP);\n            serialCommandDao.deleteByWorkflowInstanceId(workflowInstance.getId());\n            return null;\n        });\n        log.info(\"Update workflow instance {} state from: {} to {} success\",\n                workflowInstance.getName(),\n                workflowInstance.getState().name(),\n                WorkflowExecutionStatus.STOP.name());","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/executor/workflow/StopWorkflowInstanceExecutorDelegate.java#L52-L88","documentation":"Thrown by StopWorkflowInstanceExecutorDelegate.exceptionIfWorkflowInstanceCannotStop when the instance's WorkflowExecutionStatus.isCanStop() is false. Only states that can be interrupted (e.g. RUNNING, READY_PAUSE variants) may be stopped; already-finished or already-stopping instances are rejected with this message.","triggerScenarios":"Calling stop on a workflow instance in a non-stoppable state: already SUCCESS/FAILURE/STOP (final states), null state, or a state like READY_PAUSE where stop is not permitted.","commonSituations":"Clicking 'stop' twice so the second click hits an already-stopped instance; stopping an instance that already finished between list refresh and click; stopping a paused instance; stale UI showing running when the instance completed.","solutions":["Refresh the instance status; if it already reached a final state no stop is needed","Use 'pause' instead of 'stop' for states that support pausing but not stopping","Wait for READY_STOP to resolve to a final state before issuing further commands","If the instance is stuck in a non-final state, clean it up manually in the DB and restart the master"],"exampleFix":"// before\nstopDelegate.execute(stopOperation);\n// after\nif (instance.getState() != null && instance.getState().isFinalState()) {\n    return; // already finished, stop not needed\n}\nstopDelegate.execute(stopOperation);","handlingStrategy":"validation","validationCode":"WorkflowExecutionStatus st = instance.getState();\nif (st == null || !st.isCanStop()) {\n    throw new IllegalStateException(\"Instance cannot be stopped in state \" + st);\n}","typeGuard":null,"tryCatchPattern":"try {\n    delegate.execute(op);\n} catch (ServiceException e) {\n    log.warn(\"Stop rejected: {}\", e.getMessage());\n    // refresh state; skip stop if already final\n}","preventionTips":["Call isCanStop() before issuing stop","Refresh instance status before stop actions","Use pause for pausable states instead of stop","Disable stop buttons in UI for final-state instances"],"tags":["workflow","state-validation","stop"],"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"}