{"record":{"id":"47f81bfd55165790","repo":"apache/dolphinscheduler","slug":"delete-queue-by-id-error","errorCode":"DELETE_QUEUE_BY_ID_ERROR","errorMessage":"DELETE_QUEUE_BY_ID_ERROR: delete queue by id error","messagePattern":"DELETE_QUEUE_BY_ID_ERROR: delete queue by id error","errorType":"error_code","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/QueueServiceImpl.java","lineNumber":242,"sourceCode":"        if (Objects.isNull(queue)) {\n            log.error(\"Queue does not exist\");\n            throw new ServiceException(Status.QUEUE_NOT_EXIST);\n        }\n\n        List<Tenant> tenantList = tenantDao.queryTenantListByQueueId(queue.getId());\n        if (CollectionUtils.isNotEmpty(tenantList)) {\n            log.warn(\"Delete queue failed, because there are {} tenants using it.\", tenantList.size());\n            throw new ServiceException(Status.DELETE_TENANT_BY_ID_FAIL_TENANTS, tenantList.size());\n        }\n\n        List<User> userList = userDao.queryUserListByQueue(queue.getQueueName());\n        if (CollectionUtils.isNotEmpty(userList)) {\n            log.warn(\"Delete queue failed, because there are {} users using it.\", userList.size());\n            throw new ServiceException(Status.DELETE_QUEUE_BY_ID_FAIL_USERS, userList.size());\n        }\n\n        if (!queueDao.deleteById(id)) {\n            throw new ServiceException(Status.DELETE_QUEUE_BY_ID_ERROR);\n        }\n\n    }\n\n    /**\n     * verify queue and queueName\n     *\n     * @param queue queue\n     * @param queueName queue name\n     * @return true if the queue name not exists, otherwise return false\n     */\n    @Override\n    public void verifyQueue(String queue, String queueName) {\n        Queue queueValidator = new Queue(queueName, queue);\n        validQueue(queueValidator);\n    }\n\n    /**","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/QueueServiceImpl.java#L224-L260","documentation":"QueueServiceImpl.deleteQueueById throws ServiceException(Status.DELETE_QUEUE_BY_ID_ERROR) when queueDao.deleteById(id) returns false — the database delete affected no rows. All permission, existence, and reference checks passed, but the actual delete failed. This usually indicates a race (queue deleted concurrently between the existence check and the delete) or a persistence-layer problem.","triggerScenarios":"Concurrent deletion: another request removed the queue between queryById and deleteById; transaction rollback or MyBatis mapper returning 0 affected rows due to a DB constraint/trigger or connection issue.","commonSituations":"Double-clicked delete buttons issuing two near-simultaneous deletes; automated retries racing each other; database replication/lock issues causing the delete statement to affect nothing.","solutions":["Re-check whether the queue now exists — if it was deleted by a concurrent request, treat the operation as complete.","Retry the delete once after confirming the id exists; transient races resolve on the second attempt.","Check server logs and database health (locks, replication lag, mapper SQL) if the queue still exists after the failure."],"exampleFix":"// before: no concurrency handling\nqueueService.deleteQueueById(loginUser, id);\n\n// after: tolerate benign race\ntry {\n    queueService.deleteQueueById(loginUser, id);\n} catch (ServiceException e) {\n    if (queueDao.queryById(id) == null) {\n        log.info(\"Queue {} already deleted concurrently\", id);\n    } else {\n        throw e;\n    }\n}","handlingStrategy":"retry","validationCode":"// verify the queue still exists before/after retry\nif (queueDao.queryById(id) == null) { return; /* already gone */ }","typeGuard":null,"tryCatchPattern":"try {\n    queueService.deleteQueueById(loginUser, id);\n} catch (ServiceException e) {\n    if (Status.DELETE_QUEUE_BY_ID_ERROR.getCode() == e.getCode() && queueDao.queryById(id) == null) {\n        // benign race: queue already deleted concurrently\n    } else { throw e; }\n}","preventionTips":["Serialize delete operations through a single admin flow","Retry once after re-checking existence","Disable duplicate-click submission in UI tooling"],"tags":["queue-management","database","race-condition"],"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"}