{"record":{"id":"acaf5d45399fdbe1","repo":"apache/dolphinscheduler","slug":"120025","errorCode":"120025","errorMessage":"delete cluster error","messagePattern":"delete cluster error","errorType":"error_code","errorClass":"ServiceException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ClusterServiceImpl.java","lineNumber":205,"sourceCode":"     * @param loginUser login user\n     * @param code      cluster code\n     */\n    @Override\n    public void deleteClusterByCode(User loginUser, Long code) {\n        if (isNotAdmin(loginUser)) {\n            throw new ServiceException(Status.USER_NO_OPERATION_PERM);\n        }\n\n        long relatedNamespaceNumber = k8sNamespaceDao.countByClusterCode(code);\n\n        if (relatedNamespaceNumber > 0) {\n            throw new ServiceException(Status.DELETE_CLUSTER_RELATED_NAMESPACE_EXISTS);\n        }\n\n        if (clusterDao.deleteByCode(code)) {\n            return;\n        }\n        throw new ServiceException(Status.DELETE_CLUSTER_ERROR);\n    }\n\n    /**\n     * update cluster\n     *\n     * @param loginUser login user\n     * @param code      cluster code\n     * @param name      cluster name\n     * @param config    cluster config\n     * @param desc      cluster desc\n     */\n    @Override\n    public Cluster updateClusterByCode(User loginUser,\n                                       Long code,\n                                       String name,\n                                       String config,\n                                       String desc) {\n        if (isNotAdmin(loginUser)) {","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ClusterServiceImpl.java#L187-L223","documentation":"Thrown by deleteClusterByCode when clusterDao.deleteByCode(code) returns false, i.e. the delete operation on the cluster record did not remove any row. ServiceException(Status.DELETE_CLUSTER_ERROR, code 120025). Typically means the cluster row does not exist (already deleted) or the DAO delete failed silently.","triggerScenarios":"Calling deleteClusterByCode for a cluster code that no longer exists in the t_ds_cluster table, or a DB-level delete failure that made deleteByCode return false.","commonSituations":"Double-clicking a delete action / retrying an already-successful delete; deleting a cluster that was removed by another admin concurrently; DB connectivity or constraint issues causing the delete to affect zero rows.","solutions":["Check that the cluster still exists (cluster list page or clusterDao.queryByClusterCode) before deleting; if it's gone, treat the delete as already done.","Check application/DB logs for the underlying database error if the row does exist.","Retry after confirming DB connectivity; if the row exists and delete still fails, inspect the datasource configuration.","Refresh the cluster list in the UI to resync state before retrying."],"exampleFix":"// before: blind retry on failure\ntry {\n    clusterService.deleteClusterByCode(loginUser, code);\n} catch (ServiceException e) { /* retry blindly */ }\n// after: check existence first\nif (clusterDao.queryByClusterCode(code) == null) {\n    return; // already deleted\n}\nclusterService.deleteClusterByCode(loginUser, code);","handlingStrategy":"validation","validationCode":"// Java\nif (clusterDao.queryByClusterCode(code) == null) {\n    return; // nothing to delete, avoid DELETE_CLUSTER_ERROR\n}","typeGuard":null,"tryCatchPattern":"try {\n    clusterService.deleteClusterByCode(loginUser, code);\n} catch (ServiceException e) {\n    if (e.getCode() == 120025) {\n        log.warn(\"cluster {} already gone or delete failed; re-checking existence\", code);\n    } else {\n        throw e;\n    }\n}","preventionTips":["Check cluster existence before deleting","Avoid duplicate delete submissions in the UI (disable button after click)","Monitor DB health; a failing delete usually indicates datasource problems"],"tags":["cluster","delete","database"],"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"}