apache/dolphinscheduler · error · UnsupportedOperationException

updateWorkflowInstance + workflowInstanceId + state failed,

Error message

updateWorkflowInstance + workflowInstanceId + state failed, the workflow instance is not exist in db

What it means

WorkflowInstanceDaoImpl.updateWorkflowInstanceState performs a conditional UPDATE (id + original status + target status). If no row was updated it re-selects the instance; when the instance does not exist at all it throws UnsupportedOperationException stating the workflow instance is missing from the database.

Source

Thrown at dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/impl/WorkflowInstanceDaoImpl.java:73

    }

    @Override
    public void upsertWorkflowInstance(@NonNull WorkflowInstance workflowInstance) {
        if (workflowInstance.getId() != null) {
            updateById(workflowInstance);
        } else {
            insert(workflowInstance);
        }
    }

    @Override
    public void updateWorkflowInstanceState(Integer workflowInstanceId, WorkflowExecutionStatus originalStatus,
                                            WorkflowExecutionStatus targetStatus) {
        int update = mybatisMapper.updateWorkflowInstanceState(workflowInstanceId, originalStatus, targetStatus);
        if (update != 1) {
            WorkflowInstance workflowInstance = mybatisMapper.selectById(workflowInstanceId);
            if (workflowInstance == null) {
                throw new UnsupportedOperationException("updateWorkflowInstance " + workflowInstanceId
                        + " state failed, the workflow instance is not exist in db");
            }
            throw new UnsupportedOperationException(
                    "updateWorkflowInstance " + workflowInstanceId + " state failed, expect original state is "
                            + originalStatus.name() + " actual state is : {} " + workflowInstance.getState().name());
        }
    }

    @Override
    public void forceUpdateWorkflowInstanceState(Integer id, WorkflowExecutionStatus status) {
        mybatisMapper.forceUpdateWorkflowInstanceState(id, status);
    }

    /**
     * find last scheduler process instance in the date interval
     *
     * @param workflowDefinitionCode definitionCode
     * @param taskDefinitionCode    definitionCode

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Confirm the id is a workflow INSTANCE id (from t_ds_workflow_instance), not a definition id.
  2. Check the instance still exists (selectById) before attempting the state update.
  3. If deletion/cleanup can race with updates, handle the missing-instance case instead of retrying.
  4. Verify you are connected to the environment/database where the instance was created.

Example fix

// before
workflowInstanceDao.updateWorkflowInstanceState(instanceId, old, next); // throws if missing
// after
if (workflowInstanceDao.queryById(instanceId) != null) {
    workflowInstanceDao.updateWorkflowInstanceState(instanceId, old, next);
} else {
    log.warn("workflow instance {} no longer exists, skipping state update", instanceId);
}
Defensive patterns

Strategy: try-catch

Validate before calling

WorkflowInstance wi = workflowInstanceDao.queryById(instanceId);
if (wi == null) {
    log.warn("workflow instance {} not found, skip state update", instanceId);
    return;
}

Try / catch

try {
    workflowInstanceDao.updateWorkflowInstanceState(id, original, target);
} catch (UnsupportedOperationException e) {
    log.warn("state update failed, instance missing or state changed: {}", e.getMessage());
}

Prevention

When it happens

Trigger: Calling updateWorkflowInstanceState with a workflowInstanceId that has no row in t_ds_workflow_instance — e.g. after the instance was deleted, or with an id from a different/stale execution context.

Common situations: Fault-tolerance or kill-process flows referencing an instance already purged by cleanup; passing a workflowDefinition id instead of a workflowInstance id; cross-environment (stale DB) recovery.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


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