{"record":{"id":"28b4f820879c0393","repo":"apache/dolphinscheduler","slug":"updateworkflowinstance-workflowinstanceid-stat","errorCode":null,"errorMessage":"updateWorkflowInstance + workflowInstanceId + state failed, the workflow instance is not exist in db","messagePattern":"updateWorkflowInstance \\+ workflowInstanceId \\+ state failed, the workflow instance is not exist in db","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/impl/WorkflowInstanceDaoImpl.java","lineNumber":73,"sourceCode":"    }\n\n    @Override\n    public void upsertWorkflowInstance(@NonNull WorkflowInstance workflowInstance) {\n        if (workflowInstance.getId() != null) {\n            updateById(workflowInstance);\n        } else {\n            insert(workflowInstance);\n        }\n    }\n\n    @Override\n    public void updateWorkflowInstanceState(Integer workflowInstanceId, WorkflowExecutionStatus originalStatus,\n                                            WorkflowExecutionStatus targetStatus) {\n        int update = mybatisMapper.updateWorkflowInstanceState(workflowInstanceId, originalStatus, targetStatus);\n        if (update != 1) {\n            WorkflowInstance workflowInstance = mybatisMapper.selectById(workflowInstanceId);\n            if (workflowInstance == null) {\n                throw new UnsupportedOperationException(\"updateWorkflowInstance \" + workflowInstanceId\n                        + \" state failed, the workflow instance is not exist in db\");\n            }\n            throw new UnsupportedOperationException(\n                    \"updateWorkflowInstance \" + workflowInstanceId + \" state failed, expect original state is \"\n                            + originalStatus.name() + \" actual state is : {} \" + workflowInstance.getState().name());\n        }\n    }\n\n    @Override\n    public void forceUpdateWorkflowInstanceState(Integer id, WorkflowExecutionStatus status) {\n        mybatisMapper.forceUpdateWorkflowInstanceState(id, status);\n    }\n\n    /**\n     * find last scheduler process instance in the date interval\n     *\n     * @param workflowDefinitionCode definitionCode\n     * @param taskDefinitionCode    definitionCode","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/repository/impl/WorkflowInstanceDaoImpl.java#L55-L91","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Confirm the id is a workflow INSTANCE id (from t_ds_workflow_instance), not a definition id.","Check the instance still exists (selectById) before attempting the state update.","If deletion/cleanup can race with updates, handle the missing-instance case instead of retrying.","Verify you are connected to the environment/database where the instance was created."],"exampleFix":"// before\nworkflowInstanceDao.updateWorkflowInstanceState(instanceId, old, next); // throws if missing\n// after\nif (workflowInstanceDao.queryById(instanceId) != null) {\n    workflowInstanceDao.updateWorkflowInstanceState(instanceId, old, next);\n} else {\n    log.warn(\"workflow instance {} no longer exists, skipping state update\", instanceId);\n}","handlingStrategy":"try-catch","validationCode":"WorkflowInstance wi = workflowInstanceDao.queryById(instanceId);\nif (wi == null) {\n    log.warn(\"workflow instance {} not found, skip state update\", instanceId);\n    return;\n}","typeGuard":null,"tryCatchPattern":"try {\n    workflowInstanceDao.updateWorkflowInstanceState(id, original, target);\n} catch (UnsupportedOperationException e) {\n    log.warn(\"state update failed, instance missing or state changed: {}\", e.getMessage());\n}","preventionTips":["Confirm you hold a workflow instance id, not a definition id.","Check for cleanup/deletion jobs that could remove instances mid-flight.","Verify DB/environment consistency in failover scenarios."],"tags":["workflow-instance","state-update","not-found"],"backgroundTag":"entity-not-found","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"}