{"record":{"id":"61a0ca36de856169","repo":"apache/dolphinscheduler","slug":"the-workflow-instance-s-status-is-s-can-not-pa","errorCode":null,"errorMessage":"The workflow instance: %s status is %s, can not pause","messagePattern":"The workflow instance: (.+?) status is (.+?), can not pause","errorType":"exception","errorClass":"ServiceException","httpStatus":null,"severity":"warning","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/executor/workflow/PauseWorkflowInstanceExecutorDelegate.java","lineNumber":69,"sourceCode":"\n    @Override\n    public Void execute(PauseWorkflowInstanceOperation workflowInstanceControlRequest) {\n        final WorkflowInstance workflowInstance = workflowInstanceControlRequest.workflowInstance;\n        exceptionIfWorkflowInstanceCannotPause(workflowInstance);\n        if (workflowInstance.getState().isCanDirectPauseInDB()) {\n            directPauseInDB(workflowInstance);\n        } else {\n            pauseInMaster(workflowInstance);\n        }\n        return null;\n    }\n\n    private void exceptionIfWorkflowInstanceCannotPause(WorkflowInstance workflowInstance) {\n        WorkflowExecutionStatus workflowInstanceState = workflowInstance.getState();\n        if (workflowInstanceState.isCanPause()) {\n            return;\n        }\n        throw new ServiceException(\n                \"The workflow instance: \" + workflowInstance.getName() + \" status is \" + workflowInstanceState\n                        + \", can not pause\");\n    }\n\n    private void directPauseInDB(WorkflowInstance workflowInstance) {\n        // todo: move the pause logic to master\n        transactionTemplate.execute(status -> {\n            workflowInstanceDao.updateWorkflowInstanceState(\n                    workflowInstance.getId(),\n                    workflowInstance.getState(),\n                    WorkflowExecutionStatus.PAUSE);\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.PAUSE.name());","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/executor/workflow/PauseWorkflowInstanceExecutorDelegate.java#L51-L87","documentation":"Thrown when pausing a workflow instance whose current execution state does not allow pausing. The API checks WorkflowExecutionStatus.isCanPause() before sending the pause command; only states that can transition to pause (e.g. running) pass.","triggerScenarios":"Calling the pause workflow-instance API on an instance whose state is finished/success/failure/kill/stopped/paused already — any state where isCanPause() is false.","commonSituations":"User clicks pause after the workflow already completed; race between UI refresh and instance finishing; retrying a pause on an already-paused or killed instance; automation scripts pausing stale instance IDs.","solutions":["Check the instance's current state (workflow instance detail API) and only pause when it is running/pausable","Refresh the instance status before retrying — it may have finished already","Treat this as a no-op in automation: catch ServiceException and skip if the instance already ended","Use 'recover from pause' instead of pause if the instance is already paused"],"exampleFix":"// before: pause regardless of state\napi.pauseWorkflowInstance(instanceId);\n// after: check state first\nWorkflowInstance wf = api.queryWorkflowInstance(instanceId);\nif (wf.getState().isCanPause()) {\n    api.pauseWorkflowInstance(instanceId);\n}","handlingStrategy":"validation","validationCode":"WorkflowExecutionStatus st = workflowInstance.getState();\nboolean pausable = st.isCanPause();\nif (!pausable) { /* skip pause; instance state: \" + st */ }","typeGuard":"boolean canPause(WorkflowInstance wf) { return wf.getState().isCanPause(); }","tryCatchPattern":"try { delegate.pause(op); } catch (ServiceException e) { if (e.getMessage().contains(\"can not pause\")) { log.info(\"Instance already finished; ignoring pause\"); } else { throw e; } }","preventionTips":["Always fetch fresh instance state before pause operations","Treat pause of finished instances as a no-op in automation","Refresh UI data before user-triggered pause actions","Only expose the pause button for running instances"],"tags":["dolphinscheduler","workflow-state","invalid-state-transition","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"}