{"record":{"id":"0259c3f334d739bf","repo":"apache/dolphinscheduler","slug":"10087","errorCode":"10087","errorMessage":"update tenant error","messagePattern":"update tenant error","errorType":"error_code","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TenantServiceImpl.java","lineNumber":203,"sourceCode":"    public void updateTenant(User loginUser,\n                             int id,\n                             String tenantCode,\n                             int queueId,\n                             String desc) throws Exception {\n\n        if (!canOperatorPermissions(loginUser, null, AuthorizationType.TENANT, TENANT_UPDATE)) {\n            throw new ServiceException(Status.USER_NO_OPERATION_PERM);\n        }\n        if (checkDescriptionLength(desc)) {\n            throw new ServiceException(Status.DESCRIPTION_TOO_LONG_ERROR);\n        }\n        Tenant updateTenant = new Tenant(id, tenantCode, desc, queueId);\n        Tenant existsTenant = tenantDao.queryDetailById(id);\n        updateTenantValid(existsTenant, updateTenant);\n\n        updateTenant.setCreateTime(existsTenant.getCreateTime());\n        if (!tenantDao.updateById(updateTenant)) {\n            throw new ServiceException(Status.UPDATE_TENANT_ERROR);\n        }\n    }\n\n    /**\n     * delete tenant\n     *\n     * @param loginUser login user\n     * @param id        tenant id\n     * @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        }","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/TenantServiceImpl.java#L185-L221","documentation":"After validation, updateTenant calls tenantDao.updateById(updateTenant); if the DAO reports no row updated, it throws UPDATE_TENANT_ERROR (code 10087). This indicates the DB update failed or affected zero rows despite passing earlier checks.","triggerScenarios":"tenantDao.updateById returns false during PUT /tenants/update — e.g. the tenant row was deleted concurrently between queryDetailById and updateById, or a DB error caused the update to fail.","commonSituations":"Concurrent deletion of the tenant by another admin; database connectivity/constraint problems; transaction rollback leaving the row missing.","solutions":["Retry the update after re-checking the tenant still exists","Check API-server logs for the underlying SQL/DB exception","Verify DB health and that the tenant row with the given id exists"],"exampleFix":"// caller-side retry\nif (!tenantDao.updateById(updateTenant)) {\n    // re-query and retry once before failing\n    Tenant fresh = tenantDao.queryDetailById(updateTenant.getId());\n    if (fresh != null && tenantDao.updateById(updateTenant)) { return; }\n    throw new ServiceException(Status.UPDATE_TENANT_ERROR);\n}","handlingStrategy":"retry","validationCode":"Tenant exists = tenantServiceList.queryTenantList(user, code).getData().stream().filter(t -> t.getId() == id).findFirst().orElse(null); if (exists == null) return; // nothing to update","typeGuard":null,"tryCatchPattern":"try { tenantService.updateTenant(user, id, code, queueId, desc); } catch (ServiceException e) { if (e.getCode() == 10087) { /* re-query and retry once; else inspect server logs */ } }","preventionTips":["Check the tenant still exists immediately before update","Investigate DB errors in API-server logs on 10087","Avoid concurrent updates/deletes of the same tenant"],"tags":["database","persistence","tenant"],"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"}