apache/dolphinscheduler · warning · ServiceException

The workflow instance: %s status is %s, can not pause

Error message

The workflow instance: %s status is %s, can not pause

What it means

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.

Source

Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/executor/workflow/PauseWorkflowInstanceExecutorDelegate.java:69

    @Override
    public Void execute(PauseWorkflowInstanceOperation workflowInstanceControlRequest) {
        final WorkflowInstance workflowInstance = workflowInstanceControlRequest.workflowInstance;
        exceptionIfWorkflowInstanceCannotPause(workflowInstance);
        if (workflowInstance.getState().isCanDirectPauseInDB()) {
            directPauseInDB(workflowInstance);
        } else {
            pauseInMaster(workflowInstance);
        }
        return null;
    }

    private void exceptionIfWorkflowInstanceCannotPause(WorkflowInstance workflowInstance) {
        WorkflowExecutionStatus workflowInstanceState = workflowInstance.getState();
        if (workflowInstanceState.isCanPause()) {
            return;
        }
        throw new ServiceException(
                "The workflow instance: " + workflowInstance.getName() + " status is " + workflowInstanceState
                        + ", can not pause");
    }

    private void directPauseInDB(WorkflowInstance workflowInstance) {
        // todo: move the pause logic to master
        transactionTemplate.execute(status -> {
            workflowInstanceDao.updateWorkflowInstanceState(
                    workflowInstance.getId(),
                    workflowInstance.getState(),
                    WorkflowExecutionStatus.PAUSE);
            serialCommandDao.deleteByWorkflowInstanceId(workflowInstance.getId());
            return null;
        });
        log.info("Update workflow instance {} state from: {} to {} success",
                workflowInstance.getName(),
                workflowInstance.getState().name(),
                WorkflowExecutionStatus.PAUSE.name());

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Check the instance's current state (workflow instance detail API) and only pause when it is running/pausable
  2. Refresh the instance status before retrying — it may have finished already
  3. Treat this as a no-op in automation: catch ServiceException and skip if the instance already ended
  4. Use 'recover from pause' instead of pause if the instance is already paused

Example fix

// before: pause regardless of state
api.pauseWorkflowInstance(instanceId);
// after: check state first
WorkflowInstance wf = api.queryWorkflowInstance(instanceId);
if (wf.getState().isCanPause()) {
    api.pauseWorkflowInstance(instanceId);
}
Defensive patterns

Strategy: validation

Validate before calling

WorkflowExecutionStatus st = workflowInstance.getState();
boolean pausable = st.isCanPause();
if (!pausable) { /* skip pause; instance state: " + st */ }

Type guard

boolean canPause(WorkflowInstance wf) { return wf.getState().isCanPause(); }

Try / catch

try { delegate.pause(op); } catch (ServiceException e) { if (e.getMessage().contains("can not pause")) { log.info("Instance already finished; ignoring pause"); } else { throw e; } }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06). Data as JSON: /api/errors/61a0ca36de856169. Report an issue: GitHub.