apache/dolphinscheduler · error · ServiceException

DELETE_SCHEDULE_BY_ID_ERROR

DELETE_SCHEDULE_BY_ID_ERROR

Error message

DELETE_SCHEDULE_BY_ID_ERROR: delete schedule by id error

What it means

Thrown when deleting a workflow whose OFFLINE schedule record fails to be removed from the database (scheduleDao.deleteById returns false). The workflow delete aborts because the timing (schedule) row could not be cleaned up — typically a persistence-layer failure.

Source

Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java:891

                .orElseThrow(() -> new ServiceException(WORKFLOW_DEFINITION_NOT_EXIST, String.valueOf(code)));

        Project project = projectDao.queryByCode(workflowDefinition.getProjectCode());
        projectService.checkHasProjectWritePermissionThrowException(loginUser, project);

        // Determine if the login user is the owner of the workflow definition
        if (loginUser.getId() != workflowDefinition.getUserId() && loginUser.getUserType() != UserType.ADMIN_USER) {
            throw new ServiceException(Status.USER_NO_OPERATION_PERM);
        }

        workflowDefinitionUsedInOtherTaskValid(loginUser, workflowDefinition);

        // get the timing according to the workflow definition
        Schedule scheduleObj = scheduleDao.queryByWorkflowDefinitionCode(code);
        if (scheduleObj != null) {
            if (scheduleObj.getReleaseState() == ReleaseState.OFFLINE) {
                boolean delete = scheduleDao.deleteById(scheduleObj.getId());
                if (!delete) {
                    throw new ServiceException(Status.DELETE_SCHEDULE_BY_ID_ERROR);
                }
            }
            if (scheduleObj.getReleaseState() == ReleaseState.ONLINE) {
                throw new ServiceException(Status.SCHEDULE_STATE_ONLINE, scheduleObj.getId());
            }
        }

        // delete workflow instance, will delete workflow instance, sub workflow instance, task instance, alert
        workflowInstanceService.deleteWorkflowInstanceByWorkflowDefinitionCode(workflowDefinition.getCode());
        // delete task definition
        taskDefinitionService.deleteTaskByWorkflowDefinitionCode(workflowDefinition.getCode(),
                workflowDefinition.getVersion());
        // delete task definition log
        taskDefinitionLogService.deleteTaskByWorkflowDefinitionCode(workflowDefinition.getCode());
        // delete workflow definition log
        workflowDefinitionLogDao.deleteByWorkflowDefinitionCode(workflowDefinition.getCode());

        // we delete the workflow definition at last to avoid using transaction here.

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Check the metadata DB connectivity and error logs, then retry the delete.
  2. Verify the schedule row still exists (SCHEDULE_ID) and whether it was deleted by a concurrent operation.
  3. Manually remove the orphaned schedule row, then complete the workflow deletion.

Example fix

// before
boolean delete = scheduleDao.deleteById(scheduleObj.getId());
if (!delete) { throw new ServiceException(Status.DELETE_SCHEDULE_BY_ID_ERROR); }
// after
boolean delete = scheduleDao.deleteById(scheduleObj.getId());
if (!delete && scheduleDao.queryById(scheduleObj.getId()) != null) {
    throw new ServiceException(Status.DELETE_SCHEDULE_BY_ID_ERROR);
} // treat already-gone row as idempotent success
Defensive patterns

Strategy: retry

Validate before calling

// verify DB reachable and schedule row exists
Schedule s = scheduleDao.queryByWorkflowDefinitionCode(code);
boolean dbUp = dataSource.getConnection().isValid(3);

Try / catch

try { service.deleteWorkflowDefinitionByCode(user, code); }
catch (ServiceException e) { if (e.getCode() == Status.DELETE_SCHEDULE_BY_ID_ERROR) { /* retry after checking DB health */ } }

Prevention

When it happens

Trigger: scheduleDao.deleteById returning false due to DB connectivity problems, transaction conflicts, row already deleted concurrently, or constraint violations.

Common situations: Database under heavy load or transient connection loss; two operators deleting the same workflow simultaneously; replica/transaction issues in the metadata DB.

Related errors


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