{"record":{"id":"19092a39ca689b2b","repo":"apache/pulsar","slug":"failed-to-create-path","errorCode":null,"errorMessage":"Failed to create ${path}","messagePattern":"Failed to create (.+?)","errorType":"exception","errorClass":"MetadataStoreException","httpStatus":null,"severity":"error","filePath":"pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/BaseResources.java","lineNumber":189,"sourceCode":"            throw (e.getCause() instanceof MetadataStoreException) ? (MetadataStoreException) e.getCause()\n                    : new MetadataStoreException(e.getCause());\n        } catch (Exception e) {\n            throw new MetadataStoreException(\"Failed to set/create \" + path, e);\n        }\n    }\n\n    protected CompletableFuture<Void> setWithCreateAsync(String path, Function<Optional<T>, T> createFunction) {\n        return cache.readModifyUpdateOrCreate(path, createFunction).thenApply(__ -> null);\n    }\n\n    protected void create(String path, T data) throws MetadataStoreException {\n        try {\n            createAsync(path, data).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 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","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/BaseResources.java#L171-L207","documentation":"BaseResources.create writes new data to a metadata path and blocks; failures other than a plain MetadataStoreException cause (plus timeout/interruption) are wrapped as MetadataStoreException('Failed to create <path>'). Commonly the underlying cause is a node-already-exists error from the store.","triggerScenarios":"Calling create(path, data) when the path already exists, the store rejects the write, the operation times out, or the thread is interrupted.","commonSituations":"Double creation of a tenant/namespace/cluster resource by concurrent admin requests; store read-only; session expired; timeout under load.","solutions":["Check if the node already exists (exists()) and use set/setWithCreate instead of create","Handle MetadataStoreException.AlreadyExists cause explicitly","Verify metadata store write access and health","Increase operationTimeoutSec if timeouts are the cause"],"exampleFix":"// before\nresources.create(path, data);\n// after\nif (!resources.exists(path)) {\n    try { resources.create(path, data); }\n    catch (MetadataStoreException e) {\n        if (!(e.getCause() instanceof MetadataStoreException.AlreadyExistsException)) throw e;\n    }\n}","handlingStrategy":"validation","validationCode":"if (resources.exists(path)) throw new IllegalStateException(\"Node already exists: \" + path);","typeGuard":null,"tryCatchPattern":"try { resources.create(path, data); }\ncatch (MetadataStoreException e) {\n    if (e.getCause() instanceof MetadataStoreException.AlreadyExistsException) { /* idempotent handling */ }\n    else throw e;\n}","preventionTips":["Check exists() before create for idempotency","Serialize resource-creation admin requests","Use setWithCreate for create-or-update semantics"],"tags":["metadata-store","create-failure","already-exists","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"}