apache/dolphinscheduler · error · ServiceException

10143

10143

Error message

delete tenant by id fail, for there are {count} workflow definitions using it

What it means

Thrown in TenantServiceImpl.deleteTenantById when existing workflow definitions still use the tenant ({count} definitions). Referential-integrity guard: a tenant referenced by schedule/workflow definitions cannot be removed without first updating those definitions.

Source

Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TenantServiceImpl.java:235

    public void deleteTenantById(User loginUser, int id) throws Exception {

        if (!canOperatorPermissions(loginUser, null, AuthorizationType.TENANT, TENANT_DELETE)) {
            throw new ServiceException(Status.USER_NO_OPERATION_PERM);
        }

        Tenant tenant = tenantDao.queryDetailById(id);
        if (Objects.isNull(tenant)) {
            throw new ServiceException(Status.TENANT_NOT_EXIST);
        }

        List<WorkflowInstanceSummaryDto> workflowInstances = getWorkflowInstancesByTenant(tenant);
        if (CollectionUtils.isNotEmpty(workflowInstances)) {
            throw new ServiceException(Status.DELETE_TENANT_BY_ID_FAIL, workflowInstances.size());
        }

        List<Schedule> schedules = scheduleDao.queryScheduleListByTenant(tenant.getTenantCode());
        if (CollectionUtils.isNotEmpty(schedules)) {
            throw new ServiceException(Status.DELETE_TENANT_BY_ID_FAIL_DEFINES, schedules.size());
        }

        List<User> userList = userDao.queryUserListByTenant(tenant.getId());
        if (CollectionUtils.isNotEmpty(userList)) {
            throw new ServiceException(Status.DELETE_TENANT_BY_ID_FAIL_USERS, userList.size());
        }

        if (!tenantDao.deleteById(id)) {
            throw new ServiceException(Status.DELETE_TENANT_BY_ID_ERROR);
        }

        workflowInstanceDao.updateWorkflowInstanceByTenantCode(tenant.getTenantCode(), Constants.DEFAULT);
    }

    private List<WorkflowInstanceSummaryDto> getWorkflowInstancesByTenant(Tenant tenant) {
        return workflowInstanceDao.queryByTenantCodeAndStatus(
                tenant.getTenantCode(),
                WorkflowExecutionStatus.NOT_TERMINAL_STATES);

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Update the workflow definitions/schedules to use a different tenant, then retry.
  2. Delete the workflows that depend on this tenant if they are no longer needed.
  3. List schedules by tenant code to identify what must change.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TenantServiceImpl.java:235 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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