{"record":{"id":"fdbfbf6d981a683c","repo":"apache/dolphinscheduler","slug":"create-schedule-error","errorCode":"CREATE_SCHEDULE_ERROR","errorMessage":"CREATE_SCHEDULE_ERROR: create schedule error","messagePattern":"CREATE_SCHEDULE_ERROR: create schedule error","errorType":"error_code","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java","lineNumber":1421,"sourceCode":"                        ObjectNode node = (ObjectNode) jsonNodes.path(i);\n                        node.put(\"taskCode\", taskCodeMap.get(node.get(\"taskCode\").asLong()));\n                        jsonNodes.set(i, node);\n                    }\n                    workflowDefinition.setLocations(JSONUtils.toJsonString(jsonNodes));\n                }\n                // copy timing configuration\n                Schedule scheduleObj = scheduleDao.queryByWorkflowDefinitionCode(oldWorkflowDefinitionCode);\n                if (scheduleObj != null) {\n                    scheduleObj.setId(null);\n                    scheduleObj.setUserId(loginUser.getId());\n                    scheduleObj.setWorkflowDefinitionCode(workflowDefinition.getCode());\n                    scheduleObj.setReleaseState(ReleaseState.OFFLINE);\n                    scheduleObj.setCreateTime(date);\n                    scheduleObj.setUpdateTime(date);\n                    int insertResult = scheduleDao.insert(scheduleObj);\n                    if (insertResult != 1) {\n                        log.error(\"Schedule create error, workflowDefinitionCode:{}.\", workflowDefinition.getCode());\n                        throw new ServiceException(Status.CREATE_SCHEDULE_ERROR);\n                    }\n                }\n                try {\n                    createDagDefine(loginUser, taskRelationList, workflowDefinition, taskDefinitionLogs);\n                } catch (Exception e) {\n                    log.error(\"Copy workflow definition error, workflowDefinitionCode from {} to {}.\",\n                            oldWorkflowDefinitionCode, workflowDefinition.getCode(), e);\n                    failedWorkflowList.add(workflowDefinition.getCode() + \"[\" + workflowDefinition.getName() + \"]\");\n                }\n            } else {\n                log.info(\"Move workflow definition...\");\n                try {\n                    updateDagDefine(loginUser, taskRelationList, workflowDefinition, null,\n                            Lists.newArrayList());\n                } catch (Exception e) {\n                    log.error(\"Move workflow definition error, workflowDefinitionCode:{}.\",\n                            workflowDefinition.getCode(), e);\n                    failedWorkflowList.add(workflowDefinition.getCode() + \"[\" + workflowDefinition.getName() + \"]\");","sourceCodeStart":1403,"sourceCodeEnd":1439,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java#L1403-L1439","documentation":"Thrown from the batch copy-workflow flow when copying a workflow's schedule row fails: scheduleDao.insert() returns a row count other than 1, so the copied schedule could not be persisted. It is a Spring @Transactional ServiceException, so the whole copy operation (including the already-inserted workflow definition) is rolled back. It signals a database-layer write problem or constraint violation on the t_ds_schedule table, not a user-input problem.","triggerScenarios":"Calling the copy-workflow-definition API (copyWorkflowDefinition) for a source workflow that HAS a schedule, when scheduleDao.insert(scheduleObj) returns 0 or -1 — e.g. DB connection failure, unique constraint collision on the new schedule row, or schema mismatch in t_ds_schedule.","commonSituations":"Database connectivity hiccups or failover mid-copy; a corrupted/legacy t_ds_schedule schema after upgrade; running with a read-only or misconfigured metadata DB; batch-copying many workflows when the DB pool is exhausted.","solutions":["Check API server logs for the preceding 'Schedule create error, workflowDefinitionCode:...' entry and the underlying SQL exception from the DB; fix the datasource config in application.yaml if it's connectivity.","Verify t_ds_schedule schema matches the version expected by your DolphinScheduler release (run the appropriate upgrade SQL scripts).","Retry the copy once the database is healthy; the copy is transactional so no partial data remains.","If the source workflow has a stale/orphan schedule row, delete or fix it via the UI (Timing management) before copying."],"exampleFix":"// There is no user-side code fix; operator action example:\n// before: DB unreachable / schema mismatch -> insert returns != 1\n// after: verify datasource & schema\n./bin/start.sh  # after checking application.yaml datasource url/user and running dolphinscheduler_mysql.sql upgrades","handlingStrategy":"retry","validationCode":"// Verify DB connectivity and that the source workflow has a schedule before copying\nSchedule srcSchedule = scheduleDao.queryByWorkflowDefinitionCode(srcWorkflowCode);\nif (srcSchedule != null) { /* copy will attempt a schedule insert; ensure DB is healthy */ }","typeGuard":null,"tryCatchPattern":"try {\n    workflowDefinitionService.copyWorkflowDefinition(...);\n} catch (ServiceException e) {\n    if (e.getCode() == Status.CREATE_SCHEDULE_ERROR) {\n        // transaction rolled back; check DB health then retry once\n    }\n}","preventionTips":["Keep the metadata datasource (application.yaml) healthy and monitored.","Run the DolphinScheduler upgrade SQL scripts after version changes so t_ds_schedule matches the code.","Retry batch copies after transient DB failures — the copy is transactional and leaves no partial rows."],"tags":["database","schedule","copy-workflow","transactional"],"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"}