{"record":{"id":"193c8569051d99bd","repo":"apache/dolphinscheduler","slug":"schedule-state-online","errorCode":"SCHEDULE_STATE_ONLINE","errorMessage":"SCHEDULE_STATE_ONLINE: schedule {scheduleId} is already online","messagePattern":"SCHEDULE_STATE_ONLINE: schedule (.+?) is already online","errorType":"error_code","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java","lineNumber":356,"sourceCode":"        }\n        return scheduleList;\n    }\n\n    /**\n     * delete schedule by id\n     *\n     * @param loginUser   login user\n     * @param scheduleId  schedule id\n     */\n    @Override\n    public void deleteSchedulesById(User loginUser, Integer scheduleId) {\n        Schedule schedule = scheduleDao.queryById(scheduleId);\n        if (schedule == null) {\n            throw new ServiceException(Status.SCHEDULE_NOT_EXISTS, scheduleId);\n        }\n        // check schedule is already online\n        if (schedule.getReleaseState() == ReleaseState.ONLINE) {\n            throw new ServiceException(Status.SCHEDULE_STATE_ONLINE, scheduleId);\n        }\n        // Determine if the login user is the owner of the schedule\n        if (loginUser.getId() != schedule.getUserId() && loginUser.getUserType() != UserType.ADMIN_USER) {\n            throw new ServiceException(Status.USER_NO_OPERATION_PERM);\n        }\n\n        this.projectPermCheckByWorkflowCode(loginUser, schedule.getWorkflowDefinitionCode());\n        boolean delete = scheduleDao.deleteById(scheduleId);\n        if (!delete) {\n            throw new ServiceException(Status.DELETE_SCHEDULE_BY_ID_ERROR);\n        }\n    }\n\n    /**\n     * preview schedule\n     *\n     * @param loginUser login user\n     * @param schedule  schedule expression","sourceCodeStart":338,"sourceCodeEnd":374,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/SchedulerServiceImpl.java#L338-L374","documentation":"SCHEDULE_STATE_ONLINE is thrown by deleteSchedulesById when the schedule's ReleaseState is ONLINE. A schedule attached to a running quartz trigger cannot be deleted; it must first be taken offline (set to OFFLINE) via the schedule online/offline endpoint. The message interpolates the scheduleId.","triggerScenarios":"DELETE /projects/{projectCode}/schedules/{id} where the schedule was published (POST .../schedule/{id}/online was called or the UI published it) and has not been switched offline.","commonSituations":"Deleting timing configurations during a cleanup while the workflows are still scheduled and running; bulk delete scripts that skip the offline step; environments where schedules are online by default after deployment.","solutions":["Take the schedule offline first: POST /projects/{projectCode}/schedule/{id}/offline, then retry the delete.","Alternatively pause or unpublish the workflow's timing in the UI before deleting.","In bulk scripts, iterate: for each schedule check releaseState == OFFLINE before calling delete."],"exampleFix":"// before\ncurl -X DELETE '/projects/1/schedules/42'        // schedule is ONLINE -> rejected\n// after\ncurl -X POST '/projects/1/schedule/42/offline'\ncurl -X DELETE '/projects/1/schedules/42'","handlingStrategy":"validation","validationCode":"Schedule s = scheduleDao.queryById(scheduleId);\nif (s != null && s.getReleaseState() == ReleaseState.ONLINE) {\n    schedulerService.setScheduleState(loginUser, projectCode, scheduleId, ReleaseState.OFFLINE); // offline first\n}","typeGuard":null,"tryCatchPattern":"try { schedulerService.deleteSchedulesById(user, scheduleId); } catch (ServiceException e) { if (e.getCode() == Status.SCHEDULE_STATE_ONLINE) { /* call offline endpoint, then retry delete */ } }","preventionTips":["Always offline before delete: online/offline endpoint then delete","Check releaseState in UI/bulk scripts before issuing deletes","Document that published schedules are delete-protected"],"tags":["scheduler","release-state","invalid-state"],"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-14T00:17:10.932Z"}