apache/dolphinscheduler · error · ServiceException

50060

50060

Error message

delete workflow definition [{0}] error: {1}

What it means

Wrapping error in batchDeleteWorkflowDefinitionByCodes: the per-code deleteWorkflowDefinitionByCode call threw, so the loop rethrows a ServiceException carrying the workflow name and the underlying cause message. It indicates one workflow in the batch failed its individual delete (state, dependency, or DB failure).

Solutions

  1. Read the embedded cause message ({1}) to identify the specific workflow and underlying failure, then fix that condition (offline the schedule, stop instances).
  2. Delete workflows individually to isolate the failing one.
  3. Check database connectivity/constraints if the cause is a persistence error and retry after the batch partially deleted.

Example fix

// before
service.batchDeleteWorkflowDefinitionByCodes(loginUser, projectCode, allCodes); // fails on one bad workflow
// after
for (Long code : allCodes) {
    try {
        service.deleteWorkflowDefinitionByCode(loginUser, code);
    } catch (ServiceException e) {
        log.warn("skipping workflow {}: {}", code, e.getMessage());
    }
}
Defensive patterns

Strategy: try-catch

Validate before calling

List<Long> deletable = codes.stream()
    .filter(c -> workflowDefinitionDao.queryByCode(c).isPresent())
    .collect(Collectors.toList());

Try / catch

try { service.batchDeleteWorkflowDefinitionByCodes(user, projectCode, codes); }
catch (ServiceException e) { log.error("batch delete failed: {}", e.getMessage(), e); /* fall back to per-code delete */ }

Prevention

When it happens

Trigger: Batch delete where any single workflow fails its internal checks or DB operations — e.g. its sub-delete threw DELETE_SCHEDULE_BY_ID_ERROR, lineage delete failure, or a database write error.

Common situations: Batch containing a workflow with an online schedule or running instances deeper in the chain; DB connectivity issues mid-loop; foreign-key constraint from task definitions.

Related errors


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

Appendix: source

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

        Set<Long> queryCodes =
                workflowDefinitionList.stream().map(WorkflowDefinition::getCode).collect(Collectors.toSet());
        // definitionCodes - queryCodes
        Set<Long> diffCode =
                definitionCodes.stream().filter(code -> !queryCodes.contains(code)).collect(Collectors.toSet());

        if (CollectionUtils.isNotEmpty(diffCode)) {
            log.error("workflow definition does not exist, workflowDefinitionCodes:{}.",
                    diffCode.stream().map(String::valueOf).collect(Collectors.joining(Constants.COMMA)));
            throw new ServiceException(Status.BATCH_DELETE_WORKFLOW_DEFINE_BY_CODES_ERROR,
                    diffCode.stream().map(code -> code + "[workflow definition not exist]")
                            .collect(Collectors.joining(Constants.COMMA)));
        }

        for (WorkflowDefinition workflowDefinition : workflowDefinitionList) {
            try {
                this.deleteWorkflowDefinitionByCode(loginUser, workflowDefinition.getCode());
            } catch (Exception e) {
                throw new ServiceException(Status.DELETE_WORKFLOW_DEFINE_ERROR, workflowDefinition.getName(),
                        e.getMessage());
            }
        }
    }

    /**
     * workflow definition want to delete whether used in other task, should throw exception when have be used.
     * <p>
     * This function avoid delete workflow definition already dependencies by other tasks by accident.
     *
     * @param workflowDefinition WorkflowDefinition you change task definition and task relation
     */
    private void workflowDefinitionUsedInOtherTaskValid(User loginUser, WorkflowDefinition workflowDefinition) {
        // check workflow definition is already online
        if (workflowDefinition.getReleaseState() == ReleaseState.ONLINE) {
            throw new ServiceException(Status.WORKFLOW_DEFINE_STATE_ONLINE, workflowDefinition.getName());
        }

View on GitHub (pinned to 02eac45a1b)