{"record":{"id":"b4a69dff7bd74057","repo":"apache/dolphinscheduler","slug":"10165","errorCode":"10165","errorMessage":"force task success error","messagePattern":"force task success error","errorType":"error_code","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskInstanceServiceImpl.java","lineNumber":225,"sourceCode":"        WorkflowInstance workflowInstance = workflowInstanceDao.queryOptionalById(task.getWorkflowInstanceId())\n                .orElseThrow(\n                        () -> new ServiceException(Status.WORKFLOW_INSTANCE_NOT_EXIST, task.getWorkflowInstanceId()));\n        if (!workflowInstance.getState().isFinalState()) {\n            throw new ServiceException(\"The workflow instance is not finished: \" + workflowInstance.getState()\n                    + \" cannot force start task instance\");\n        }\n\n        // check whether the task instance state type is failure or cancel\n        if (!task.getState().isFailure() && !task.getState().isKill()) {\n            throw new ServiceException(Status.TASK_INSTANCE_STATE_OPERATION_ERROR, taskInstanceId, task.getState());\n        }\n\n        // change the state of the task instance\n        task.setState(TaskExecutionStatus.FORCED_SUCCESS);\n        task.setEndTime(new Date());\n        boolean changed = taskInstanceDao.updateById(task);\n        if (!changed) {\n            throw new ServiceException(Status.FORCE_TASK_SUCCESS_ERROR);\n        }\n        processService.forceWorkflowInstanceSuccessByTaskInstanceId(task);\n        log.info(\"Force success task instance id: {} success\", taskInstanceId);\n    }\n\n    @Override\n    public Result taskSavePoint(User loginUser, long projectCode, Integer taskInstanceId) {\n        Result result = new Result();\n\n        Project project = projectDao.queryByCode(projectCode);\n        projectService.checkHasProjectWritePermissionThrowException(loginUser, project);\n\n        TaskInstance taskInstance = taskInstanceDao.queryById(taskInstanceId);\n        if (taskInstance == null || taskInstance.getProjectCode() != projectCode) {\n            log.error(\"Task definition can not be found, projectCode:{}, taskInstanceId:{}.\", projectCode,\n                    taskInstanceId);\n            putMsg(result, Status.TASK_INSTANCE_NOT_FOUND);\n            return result;","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TaskInstanceServiceImpl.java#L207-L243","documentation":"Status.FORCE_TASK_SUCCESS_ERROR, thrown when the DAO update persisting FORCED_SUCCESS state on the task instance returns false (no row updated). The validation passed and the state was set in memory, but the database write did not change any row, indicating the instance row vanished or a concurrency race modified it.","triggerScenarios":"taskInstanceDao.updateById(task) returns false — typically the task instance row was deleted by another process between read and update, or an optimistic/concurrent update overwrote it so the update affected 0 rows.","commonSituations":"Two operators click force-success simultaneously; a cleanup job purges old task instances while an admin is force-succeeding them; DB connectivity issues surfaced as zero-row updates.","solutions":["Refresh the task instance and retry once — the first update may have already applied (check state == FORCED_SUCCESS).","Check server logs around the time for concurrent modifications or deletes of the task instance.","Verify the task instance still exists in the DB (t_ds_task_instance) with the given id.","If it recurs, serialize force-success operations per task (lock or UI dedup) and check database connectivity."],"exampleFix":"// before\nboolean changed = taskInstanceDao.updateById(task);\nif (!changed) { throw new ServiceException(Status.FORCE_TASK_SUCCESS_ERROR); }\n// after\nboolean changed = taskInstanceDao.updateById(task);\nif (!changed) {\n    TaskInstance fresh = taskInstanceDao.queryById(task.getId());\n    if (fresh == null || fresh.getState() != TaskExecutionStatus.FORCED_SUCCESS) {\n        throw new ServiceException(Status.FORCE_TASK_SUCCESS_ERROR);\n    }\n}","handlingStrategy":"retry","validationCode":"// pre-check that the row still exists before update\nif (taskInstanceDao.queryOptionalById(id).isEmpty()) {\n    throw new IllegalStateException(\"task instance \" + id + \" no longer exists\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    taskInstanceService.forceTaskSuccess(loginUser, projectCode, id);\n} catch (ServiceException e) {\n    if (e.getCode() == 10165) {\n        // re-read the task; if already FORCED_SUCCESS, treat as success, else retry once\n    }\n}","preventionTips":["Serialize force-success calls per task instance","Check for concurrent cleanup jobs deleting instances","Verify DB connectivity if updates consistently affect 0 rows","Re-read state after failure before retrying"],"tags":["database","concurrency","task-instance","write-failed"],"backgroundTag":"database-write-failed","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"}