{"record":{"id":"32f7cddbc5e80bbd","repo":"apache/dolphinscheduler","slug":"schedule-state-online-32f7cd","errorCode":"SCHEDULE_STATE_ONLINE","errorMessage":"SCHEDULE_STATE_ONLINE: the schedule [{0}] is online, can not be deleted","messagePattern":"SCHEDULE_STATE_ONLINE: the schedule \\[(.+?)\\] is online, can not be deleted","errorType":"error_code","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java","lineNumber":895,"sourceCode":"\n        // Determine if the login user is the owner of the workflow definition\n        if (loginUser.getId() != workflowDefinition.getUserId() && loginUser.getUserType() != UserType.ADMIN_USER) {\n            throw new ServiceException(Status.USER_NO_OPERATION_PERM);\n        }\n\n        workflowDefinitionUsedInOtherTaskValid(loginUser, workflowDefinition);\n\n        // get the timing according to the workflow definition\n        Schedule scheduleObj = scheduleDao.queryByWorkflowDefinitionCode(code);\n        if (scheduleObj != null) {\n            if (scheduleObj.getReleaseState() == ReleaseState.OFFLINE) {\n                boolean delete = scheduleDao.deleteById(scheduleObj.getId());\n                if (!delete) {\n                    throw new ServiceException(Status.DELETE_SCHEDULE_BY_ID_ERROR);\n                }\n            }\n            if (scheduleObj.getReleaseState() == ReleaseState.ONLINE) {\n                throw new ServiceException(Status.SCHEDULE_STATE_ONLINE, scheduleObj.getId());\n            }\n        }\n\n        // delete workflow instance, will delete workflow instance, sub workflow instance, task instance, alert\n        workflowInstanceService.deleteWorkflowInstanceByWorkflowDefinitionCode(workflowDefinition.getCode());\n        // delete task definition\n        taskDefinitionService.deleteTaskByWorkflowDefinitionCode(workflowDefinition.getCode(),\n                workflowDefinition.getVersion());\n        // delete task definition log\n        taskDefinitionLogService.deleteTaskByWorkflowDefinitionCode(workflowDefinition.getCode());\n        // delete workflow definition log\n        workflowDefinitionLogDao.deleteByWorkflowDefinitionCode(workflowDefinition.getCode());\n\n        // we delete the workflow definition at last to avoid using transaction here.\n        // If delete error, we can call this interface again.\n        workflowDefinitionDao.deleteByWorkflowDefinitionCode(workflowDefinition.getCode());\n\n        // delete workflow lineage (lineage data only keeps one record per workflow code)","sourceCodeStart":877,"sourceCodeEnd":913,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java#L877-L913","documentation":"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.","triggerScenarios":"Deleting a workflow that still has an active scheduler timing enabled (schedule releaseState=ONLINE).","commonSituations":"Deleting production workflows with daily/hourly crons without first disabling the schedule; automation that only sets the workflow OFFLINE but forgets the schedule.","solutions":["Take the schedule OFFLINE (scheduleService offline / updateSchedule with ReleaseState.OFFLINE) using the schedule id from the message.","Retry the workflow delete after the schedule is offline.","Delete the online schedule explicitly if the workflow is being permanently retired."],"exampleFix":"// before\nservice.deleteWorkflowDefinitionByCode(loginUser, code); // schedule ONLINE -> throws\n// after\nSchedule s = scheduleDao.queryByWorkflowDefinitionCode(code);\nscheduleService.updateSchedule(loginUser, s.getProjectCode(), s.getId(), offlineParams); // set ReleaseState.OFFLINE\nservice.deleteWorkflowDefinitionByCode(loginUser, code);","handlingStrategy":"validation","validationCode":"Schedule s = scheduleDao.queryByWorkflowDefinitionCode(code);\nif (s != null && s.getReleaseState() == ReleaseState.ONLINE) {\n    // offline the schedule before deleting the workflow\n    scheduleService.updateSchedule(user, s.getProjectCode(), s.getId(), offlineParams);\n}","typeGuard":null,"tryCatchPattern":"try { service.deleteWorkflowDefinitionByCode(user, code); }\ncatch (ServiceException e) { if (e.getCode() == Status.SCHEDULE_STATE_ONLINE) { /* offline schedule from e args, retry */ } }","preventionTips":["Always offline timings before workflow deletion","Audit schedules when retiring workflows","Include schedule offlining in teardown scripts"],"tags":["schedule","release-state","state-guard"],"backgroundTag":"invalid-state-transition","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}