apache/dolphinscheduler · error · ServiceException

DELETE_QUEUE_BY_ID_FAIL_USERS

DELETE_QUEUE_BY_ID_FAIL_USERS

Error message

DELETE_QUEUE_BY_ID_FAIL_USERS: {userCount} users are using this queue, delete failed

What it means

QueueServiceImpl.deleteQueueById throws ServiceException(Status.DELETE_QUEUE_BY_ID_FAIL_USERS, userCount) when users still reference the queue by name: userDao.queryUserListByQueue(queue.getQueueName()) returns a non-empty list. This is a second referential-integrity guard, after the tenant check; queues referenced by user records cannot be deleted. The message interpolates the number of blocking users.

Source

Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/QueueServiceImpl.java:238

            throw new ServiceException(Status.USER_NO_OPERATION_PERM);
        }

        Queue queue = queueDao.queryById(id);
        if (Objects.isNull(queue)) {
            log.error("Queue does not exist");
            throw new ServiceException(Status.QUEUE_NOT_EXIST);
        }

        List<Tenant> tenantList = tenantDao.queryTenantListByQueueId(queue.getId());
        if (CollectionUtils.isNotEmpty(tenantList)) {
            log.warn("Delete queue failed, because there are {} tenants using it.", tenantList.size());
            throw new ServiceException(Status.DELETE_TENANT_BY_ID_FAIL_TENANTS, tenantList.size());
        }

        List<User> userList = userDao.queryUserListByQueue(queue.getQueueName());
        if (CollectionUtils.isNotEmpty(userList)) {
            log.warn("Delete queue failed, because there are {} users using it.", userList.size());
            throw new ServiceException(Status.DELETE_QUEUE_BY_ID_FAIL_USERS, userList.size());
        }

        if (!queueDao.deleteById(id)) {
            throw new ServiceException(Status.DELETE_QUEUE_BY_ID_ERROR);
        }

    }

    /**
     * verify queue and queueName
     *
     * @param queue queue
     * @param queueName queue name
     * @return true if the queue name not exists, otherwise return false
     */
    @Override
    public void verifyQueue(String queue, String queueName) {
        Queue queueValidator = new Queue(queueName, queue);

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Update each blocking user's queue to another queue (user management API/UI), then retry the delete.
  2. Find the users via the reported count: query t_ds_user WHERE queue = '<queueName>' and reassign them.
  3. If the user-level queue field is unused in your deployment, clear it (set to default) for those users, then delete the queue.

Example fix

// before
deleteQueueById(loginUser, 7) -> DELETE_QUEUE_BY_ID_FAIL_USERS (2 users)

// after: reassign users first
userService.updateUser(loginUser, userId, ..., "default"); // for each blocking user
deleteQueueById(loginUser, 7) -> succeeds
Defensive patterns

Strategy: validation

Validate before calling

// check user references before deleting
List<User> users = userDao.queryUserListByQueue(queueName);
if (!users.isEmpty()) {
    throw new IllegalStateException("Queue " + queueName + " still used by " + users.size() + " user(s)");
}

Try / catch

try {
    queueService.deleteQueueById(loginUser, id);
} catch (ServiceException e) {
    if (Status.DELETE_QUEUE_BY_ID_FAIL_USERS.getCode() == e.getCode()) {
        // reassign users then retry
    } else { throw e; }
}

Prevention

When it happens

Trigger: Deleting a queue while rows in t_ds_user have queue equal to the queue's queueName; legacy user records still carrying the queue name after tenants were migrated off it.

Common situations: After reassigning tenants but forgetting that individual users also carry a queue field; old user profiles pointing at a decommissioned YARN queue; data migrated from older DolphinScheduler versions keeping the user.queue column populated.

Related errors


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