{"record":{"id":"3b7a5541905dea23","repo":"apache/dolphinscheduler","slug":"10144","errorCode":"10144","errorMessage":"delete tenant by id fail, for there are {count} users using it","messagePattern":"delete tenant by id fail, for there are (.+?) users using it","errorType":"error_code","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TenantServiceImpl.java","lineNumber":240,"sourceCode":"\n        Tenant tenant = tenantDao.queryDetailById(id);\n        if (Objects.isNull(tenant)) {\n            throw new ServiceException(Status.TENANT_NOT_EXIST);\n        }\n\n        List<WorkflowInstanceSummaryDto> workflowInstances = getWorkflowInstancesByTenant(tenant);\n        if (CollectionUtils.isNotEmpty(workflowInstances)) {\n            throw new ServiceException(Status.DELETE_TENANT_BY_ID_FAIL, workflowInstances.size());\n        }\n\n        List<Schedule> schedules = scheduleDao.queryScheduleListByTenant(tenant.getTenantCode());\n        if (CollectionUtils.isNotEmpty(schedules)) {\n            throw new ServiceException(Status.DELETE_TENANT_BY_ID_FAIL_DEFINES, schedules.size());\n        }\n\n        List<User> userList = userDao.queryUserListByTenant(tenant.getId());\n        if (CollectionUtils.isNotEmpty(userList)) {\n            throw new ServiceException(Status.DELETE_TENANT_BY_ID_FAIL_USERS, userList.size());\n        }\n\n        if (!tenantDao.deleteById(id)) {\n            throw new ServiceException(Status.DELETE_TENANT_BY_ID_ERROR);\n        }\n\n        workflowInstanceDao.updateWorkflowInstanceByTenantCode(tenant.getTenantCode(), Constants.DEFAULT);\n    }\n\n    private List<WorkflowInstanceSummaryDto> getWorkflowInstancesByTenant(Tenant tenant) {\n        return workflowInstanceDao.queryByTenantCodeAndStatus(\n                tenant.getTenantCode(),\n                WorkflowExecutionStatus.NOT_TERMINAL_STATES);\n    }\n\n    /**\n     * query tenant list\n     *","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TenantServiceImpl.java#L222-L258","documentation":"Thrown in TenantServiceImpl.deleteTenantById when user accounts are still bound to the tenant ({count} users). A tenant with attached users cannot be deleted; the users must be reassigned to another tenant first.","triggerScenarios":"Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TenantServiceImpl.java:240 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reassign the affected users to a different tenant, then retry the delete.","Delete or disable the user accounts bound to this tenant if appropriate.","Query the user list by tenant to see which accounts block deletion."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}