{"record":{"id":"d68d3534e170ed3d","repo":"apache/dolphinscheduler","slug":"the-workflow-instance-s-status-is-s-cannot-rep","errorCode":null,"errorMessage":"The workflow instance: %s status is %s, cannot repeat running","messagePattern":"The workflow instance: (.+?) status is (.+?), cannot repeat running","errorType":"exception","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/executor/workflow/RepeatRunningWorkflowInstanceExecutorDelegate.java","lineNumber":46,"sourceCode":"import org.apache.dolphinscheduler.registry.api.RegistryClient;\nimport org.apache.dolphinscheduler.registry.api.enums.RegistryNodeType;\n\nimport org.springframework.beans.factory.annotation.Autowired;\nimport org.springframework.stereotype.Component;\n\n@Component\npublic class RepeatRunningWorkflowInstanceExecutorDelegate\n        implements\n            IExecutorDelegate<RepeatRunningWorkflowInstanceExecutorDelegate.RepeatRunningWorkflowInstanceOperation, Void> {\n\n    @Autowired\n    private RegistryClient registryClient;\n\n    @Override\n    public Void execute(RepeatRunningWorkflowInstanceOperation workflowInstanceControlRequest) {\n        final WorkflowInstance workflowInstance = workflowInstanceControlRequest.workflowInstance;\n        if (workflowInstance.getState() == null || !workflowInstance.getState().isFinalState()) {\n            throw new ServiceException(\n                    String.format(\"The workflow instance: %s status is %s, cannot repeat running\",\n                            workflowInstance.getName(), workflowInstance.getState()));\n        }\n\n        final Server masterServer = registryClient.getRandomServer(RegistryNodeType.MASTER).orElse(null);\n        if (masterServer == null) {\n            throw new ServiceException(\"no master server available\");\n        }\n        final WorkflowInstanceRepeatRunningRequest repeatRunningRequest = WorkflowInstanceRepeatRunningRequest.builder()\n                .workflowInstanceId(workflowInstance.getId())\n                .userId(workflowInstanceControlRequest.executeUser.getId())\n                .build();\n\n        final WorkflowInstanceRepeatRunningResponse repeatRunningResponse = Clients\n                .withService(IWorkflowControlClient.class)\n                .withHost(masterServer.getHost() + \":\" + masterServer.getPort())\n                .repeatTriggerWorkflowInstance(repeatRunningRequest);\n        if (!repeatRunningResponse.isSuccess()) {","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/executor/workflow/RepeatRunningWorkflowInstanceExecutorDelegate.java#L28-L64","documentation":"Thrown by RepeatRunningWorkflowInstanceExecutorDelegate.execute when the target workflow instance is not in a final state (SUCCESS, FAILURE, STOP, etc.) or its state is null. Repeat-running is only allowed for finished instances, so the delegate rejects the request before contacting the master.","triggerScenarios":"Calling repeat-running on an instance whose WorkflowExecutionStatus is not isFinalState() — e.g. the instance is RUNNING, READY_PAUSE, READY_STOP, or has a null state.","commonSituations":"Double-clicking 'rerun' in the UI while the instance is still executing; trying to rerun an instance that is currently being stopped; stale list data showing an old status; an instance stuck in a non-final state after a master crash.","solutions":["Wait until the workflow instance reaches a final state (SUCCESS/FAILURE/STOP) then retry repeat-running","Stop the running instance first, wait for it to reach a final state, then repeat-run it","Refresh the instance status from the DB/UI to clear stale state assumptions","If stuck non-final, manually correct the instance state in the DB (t_master_command cleanup) and restart as needed"],"exampleFix":"// before\nrepeatRunning(instance);\n// after\nif (instance.getState() == null || !instance.getState().isFinalState()) {\n    throw new ServiceException(\"Wait for final state before repeat running: \" + instance.getName());\n}\nrepeatRunning(instance);","handlingStrategy":"validation","validationCode":"WorkflowExecutionStatus st = instance.getState();\nif (st == null || !st.isFinalState()) {\n    throw new IllegalStateException(\"Cannot repeat-run instance in state \" + st);\n}","typeGuard":null,"tryCatchPattern":"try {\n    delegate.execute(op);\n} catch (ServiceException e) {\n    log.warn(\"Repeat running rejected: {}\", e.getMessage());\n    // re-fetch instance state and inform user to wait for final state\n}","preventionTips":["Check isFinalState() before requesting repeat-run","Refresh UI state before rerun actions","Handle already-running instances by stopping first","Guard against stale cached instance status"],"tags":["workflow","state-validation","rerun"],"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-14T00:17:10.932Z"}