apache/dolphinscheduler · error · ServiceException

SCHEDULE_STATE_ONLINE

SCHEDULE_STATE_ONLINE

Error message

SCHEDULE_STATE_ONLINE: the schedule [{0}] is online, can not be deleted

What it means

Thrown when the workflow definition has a schedule whose release state is ONLINE. A live (online) timing must be taken offline before the workflow can be deleted; the message includes the schedule id.

Source

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

        // 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.
        // If delete error, we can call this interface again.
        workflowDefinitionDao.deleteByWorkflowDefinitionCode(workflowDefinition.getCode());

        // delete workflow lineage (lineage data only keeps one record per workflow code)

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Take the schedule OFFLINE (scheduleService offline / updateSchedule with ReleaseState.OFFLINE) using the schedule id from the message.
  2. Retry the workflow delete after the schedule is offline.
  3. Delete the online schedule explicitly if the workflow is being permanently retired.

Example fix

// before
service.deleteWorkflowDefinitionByCode(loginUser, code); // schedule ONLINE -> throws
// after
Schedule s = scheduleDao.queryByWorkflowDefinitionCode(code);
scheduleService.updateSchedule(loginUser, s.getProjectCode(), s.getId(), offlineParams); // set ReleaseState.OFFLINE
service.deleteWorkflowDefinitionByCode(loginUser, code);
Defensive patterns

Strategy: validation

Validate before calling

Schedule s = scheduleDao.queryByWorkflowDefinitionCode(code);
if (s != null && s.getReleaseState() == ReleaseState.ONLINE) {
    // offline the schedule before deleting the workflow
    scheduleService.updateSchedule(user, s.getProjectCode(), s.getId(), offlineParams);
}

Try / catch

try { service.deleteWorkflowDefinitionByCode(user, code); }
catch (ServiceException e) { if (e.getCode() == Status.SCHEDULE_STATE_ONLINE) { /* offline schedule from e args, retry */ } }

Prevention

When it happens

Trigger: Deleting a workflow that still has an active scheduler timing enabled (schedule releaseState=ONLINE).

Common situations: Deleting production workflows with daily/hourly crons without first disabling the schedule; automation that only sets the workflow OFFLINE but forgets the schedule.

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/32f7cddbc5e80bbd. Report an issue: GitHub.