{"record":{"id":"ba0791230fc6791f","repo":"apache/dolphinscheduler","slug":"10142","errorCode":"10142","errorMessage":"delete tenant by id fail, for there are {count} workflow instances in executing using it","messagePattern":"delete tenant by id fail, for there are (.+?) workflow instances in executing 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":230,"sourceCode":"     * @return delete result code\n     * @throws Exception exception\n     */\n    @Override\n    @Transactional()\n    public void deleteTenantById(User loginUser, int id) throws Exception {\n\n        if (!canOperatorPermissions(loginUser, null, AuthorizationType.TENANT, TENANT_DELETE)) {\n            throw new ServiceException(Status.USER_NO_OPERATION_PERM);\n        }\n\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    }","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TenantServiceImpl.java#L212-L248","documentation":"Thrown in TenantServiceImpl.deleteTenantById when running workflow instances still reference the tenant ({count} instances). Deleting a tenant in use by executing workflows would break those instances, so the delete is blocked until they finish or are stopped.","triggerScenarios":"Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TenantServiceImpl.java:230 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Wait for the running workflow instances to complete, or stop/kill them, then retry the delete.","Reassign those workflow instances to another tenant.","Check the workflow instance list filtered by this tenant to find the blocking instances."],"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"}