apache/dolphinscheduler · error · ServiceException

ASSIGN_WORKER_GROUP_TO_PROJECT_ERROR

ASSIGN_WORKER_GROUP_TO_PROJECT_ERROR

Error message

ASSIGN_WORKER_GROUP_TO_PROJECT_ERROR: assign worker group to project error

What it means

Thrown when deletion of project worker-group relations succeeded partially or failed (projectWorkerGroupDao.deleteByProjectCodeAndWorkerGroups returned false), meaning the assign operation could not complete. Indicates a persistence failure rather than a validation error.

Solutions

  1. Check DB connectivity and server logs for the preceding 'Failed to delete worker groups' error
  2. Verify the relation rows still exist (maybe already deleted — the operation may effectively be done)
  3. Retry the assignment; make deletion idempotent if races are the cause

Example fix

// before
boolean deleted = projectWorkerGroupDao.deleteByProjectCodeAndWorkerGroups(projectCode, groups);
if (deleted) { ... } else { throw new ServiceException(Status.ASSIGN_WORKER_GROUP_TO_PROJECT_ERROR); }
// after
projectWorkerGroupDao.deleteByProjectCodeAndWorkerGroups(projectCode, groups); // treat 0 rows as success/idempotent
log.info("Deleted worker groups [{}] for project [{}] (idempotent).", groups, project.getName());
Defensive patterns

Strategy: retry

Try / catch

try {
    service.assignWorkerGroupsToProject(loginUser, projectCode, assign, delete);
} catch (ServiceException e) {
    if (e.getCode() == Status.ASSIGN_WORKER_GROUP_TO_PROJECT_ERROR) {
        // inspect current relations, then retry idempotently
        retryAfterDelay();
    } else { throw e; }
}

Prevention

When it happens

Trigger: deleteByProjectCodeAndWorkerGroups returns false (no rows affected / DB issue) after passing the in-use validation, inside assignWorkerGroupsToProject.

Common situations: Database connection issues; the rows were already deleted by a concurrent request (0 rows affected treated as failure); transaction conflicts.

Related errors


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

Appendix: source

Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProjectWorkerGroupRelationServiceImpl.java:163

        if (CollectionUtils.isNotEmpty(needDeletedWorkerGroups)) {
            Set<String> usedWorkerGroups = getAllUsedWorkerGroups(project);
            if (CollectionUtils.isNotEmpty(usedWorkerGroups) && CollectionUtils.isNotEmpty(needDeletedWorkerGroups)) {
                Set<String> shouldNotDelete = SetUtils.intersection(usedWorkerGroups, needDeletedWorkerGroups);
                if (CollectionUtils.isNotEmpty(shouldNotDelete)) {
                    throw new ServiceException(Status.USED_WORKER_GROUP_EXISTS, shouldNotDelete);
                }
            }
            boolean deleted =
                    projectWorkerGroupDao.deleteByProjectCodeAndWorkerGroups(projectCode,
                            new ArrayList<>(needDeletedWorkerGroups));
            if (deleted) {
                log.info("Success to delete worker groups [{}] for the project [{}] .", needDeletedWorkerGroups,
                        project.getName());
            } else {
                log.error("Failed to delete worker groups [{}] for the project [{}].", needDeletedWorkerGroups,
                        project.getName());
                throw new ServiceException(Status.ASSIGN_WORKER_GROUP_TO_PROJECT_ERROR);
            }
        }

        Set<String> needAssignedWorkerGroups =
                SetUtils.difference(unauthorizedWorkerGroupNames, projectWorkerGroupNames);
        if (CollectionUtils.isNotEmpty(needAssignedWorkerGroups)) {
            needAssignedWorkerGroups.forEach(workerGroupName -> {
                ProjectWorkerGroup projectWorkerGroup = new ProjectWorkerGroup();
                projectWorkerGroup.setProjectCode(projectCode);
                projectWorkerGroup.setWorkerGroup(workerGroupName);
                projectWorkerGroup.setCreateTime(now);
                projectWorkerGroup.setUpdateTime(now);
                int create = projectWorkerGroupDao.insert(projectWorkerGroup);
                if (create > 0) {
                    log.info("Success to add worker group [{}] for the project [{}] .", workerGroupName,
                            project.getName());
                } else {
                    log.error("Failed to add worker group [{}] for the project [{}].", workerGroupName,

View on GitHub (pinned to 02eac45a1b)