{"record":{"id":"3fcdc4b69b5e18f2","repo":"apache/pulsar","slug":"failed-to-delete-path","errorCode":null,"errorMessage":"Failed to delete ${path}","messagePattern":"Failed to delete (.+?)","errorType":"exception","errorClass":"MetadataStoreException","httpStatus":null,"severity":"error","filePath":"pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/BaseResources.java","lineNumber":204,"sourceCode":"            throw (e.getCause() instanceof MetadataStoreException) ? (MetadataStoreException) e.getCause()\n                    : new MetadataStoreException(e.getCause());\n        } catch (Exception e) {\n            throw new MetadataStoreException(\"Failed to create \" + path, e);\n        }\n    }\n\n    protected CompletableFuture<Void> createAsync(String path, T data) {\n        return cache.create(path, data);\n    }\n\n    protected void delete(String path) throws MetadataStoreException {\n        try {\n            deleteAsync(path).get(operationTimeoutSec, TimeUnit.SECONDS);\n        } catch (ExecutionException e) {\n            throw (e.getCause() instanceof MetadataStoreException) ? (MetadataStoreException) e.getCause()\n                    : new MetadataStoreException(e.getCause());\n        } catch (Exception e) {\n            throw new MetadataStoreException(\"Failed to delete \" + path, e);\n        }\n    }\n\n    protected CompletableFuture<Void> deleteAsync(String path) {\n        return cache.delete(path);\n    }\n\n    protected CompletableFuture<Void> deleteIfExistsAsync(String path) {\n        log.info().attr(\"path\", path).log(\"Deleting path\");\n        CompletableFuture<Void> future = new CompletableFuture<>();\n        cache.delete(path).whenComplete((ignore, ex) -> {\n            if (ex != null && ex.getCause() instanceof MetadataStoreException.NotFoundException) {\n                log.info().attr(\"path\", path).log(\"Path did not exist in metadata store\");\n                future.complete(null);\n            } else if (ex != null) {\n                log.info().attr(\"path\", path).exception(ex).log(\"Failed to delete path from metadata store\");\n                future.completeExceptionally(ex);\n            } else {","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/BaseResources.java#L186-L222","documentation":"BaseResources.delete removes a metadata path synchronously; unexpected causes, timeouts, and interruptions are wrapped as MetadataStoreException('Failed to delete <path>'). Often the cause is a not-empty or not-found error from the metadata store.","triggerScenarios":"Calling delete(path) when the node has children (non-recursive delete rejected), the node was already deleted, the store is unavailable, or the timeout elapses.","commonSituations":"Deleting a parent namespace/tenant node that still has children; concurrent deletion by another admin; ZooKeeper session expired; slow store exceeding timeout.","solutions":["Delete child nodes first or use the recursive delete path in the admin resources layer","Check the cause: not-found may be benign — treat idempotently","Verify metadata store health and session state","Increase operationTimeoutSec for deep trees"],"exampleFix":"// before\nresources.delete(path);\n// after\ntry { resources.delete(path); }\ncatch (MetadataStoreException e) {\n    if (e.getCause() instanceof MetadataStoreException.NotFoundException) { /* already gone */ }\n    else throw e;\n}","handlingStrategy":"try-catch","validationCode":"if (resources.exists(path) && !resources.getChildren(path).isEmpty()) throw new IllegalStateException(\"Node has children: \" + path);","typeGuard":null,"tryCatchPattern":"try { resources.delete(path); }\ncatch (MetadataStoreException e) {\n    if (causeIsNotFound(e.getCause())) { /* already deleted: treat as success */ }\n    else throw e;\n}","preventionTips":["Delete children before parent nodes","Make deletes idempotent (ignore not-found)","Monitor store sessions during cleanup jobs"],"tags":["metadata-store","delete-failure","exception-wrapping"],"backgroundTag":"metadata-store-operation-failed","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}