{"record":{"id":"bf74af33de90586b","repo":"apache/pulsar","slug":"failed-to-check-exist-path","errorCode":null,"errorMessage":"Failed to check exist ${path}","messagePattern":"Failed to check exist (.+?)","errorType":"exception","errorClass":"MetadataStoreException","httpStatus":null,"severity":"error","filePath":"pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/BaseResources.java","lineNumber":237,"sourceCode":"            } 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 {\n                log.info().attr(\"path\", path).log(\"Deleted path from metadata store\");\n                future.complete(null);\n            }\n        });\n        return future;\n    }\n\n    protected boolean exists(String path) throws MetadataStoreException {\n        try {\n            return cache.exists(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 check exist \" + path, e);\n        }\n    }\n\n    protected CompletableFuture<Boolean> existsAsync(String path) {\n        return cache.exists(path);\n    }\n\n    public int getOperationTimeoutSec() {\n        return operationTimeoutSec;\n    }\n\n    protected static String joinPath(String... parts) {\n        StringBuilder sb = new StringBuilder();\n        Joiner.on('/').appendTo(sb, parts);\n        return sb.toString();\n    }\n}","sourceCodeStart":219,"sourceCodeEnd":254,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/BaseResources.java#L219-L254","documentation":"BaseResources.exists checks node presence synchronously; unexpected causes, timeout, or interruption are wrapped as MetadataStoreException('Failed to check exist <path>'). It means the existence probe itself failed, not that the node is absent — absence returns false without throwing.","triggerScenarios":"Calling exists(path) when the metadata store connection fails, the operation exceeds operationTimeoutSec, or the blocking get is interrupted.","commonSituations":"Metadata store outage or session expiry; transient network blips during existence checks before create/delete; misconfigured metadata store URL; too-short timeout under load.","solutions":["Check metadata store connectivity and session health in broker logs","Retry the existence check after transient failures","Increase operationTimeoutSec","Distinguish false (node absent) from thrown exception (check failed) in caller logic"],"exampleFix":"// before\nif (resources.exists(path)) { ... }\n// after\nboolean exists;\ntry { exists = resources.exists(path); }\ncatch (MetadataStoreException e) {\n    throw new PulsarServerException(\"Existence check failed for \" + path, e.getCause());\n}\nif (exists) { ... }","handlingStrategy":"retry","validationCode":"// verify store reachable before probing\nif (!metadataStoreReachable()) throw new IllegalStateException(\"Metadata store unreachable\");","typeGuard":null,"tryCatchPattern":"try { exists = resources.exists(path); }\ncatch (MetadataStoreException e) {\n    // existence check failed ≠ node absent\n    throw new PulsarServerException(\"exists() check failed for \" + path, e.getCause());\n}","preventionTips":["Never interpret a thrown exists() failure as 'node absent'","Retry transient store errors with backoff","Keep operationTimeoutSec comfortably above p99 store latency"],"tags":["metadata-store","timeout","exists-check","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-14T05:17:10.506Z"}