{"record":{"id":"08229052c10bd941","repo":"apache/pulsar","slug":"path-s-not-found","errorCode":null,"errorMessage":"path %s not found.","messagePattern":"path (.+?) not found\\.","errorType":"exception","errorClass":"MetadataStoreException.NotFoundException","httpStatus":null,"severity":"error","filePath":"pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/RocksdbMetadataStore.java","lineNumber":570,"sourceCode":"        } finally {\n            dbStateLock.readLock().unlock();\n        }\n    }\n\n    @Override\n    protected CompletableFuture<Void> storeDelete(String path, Optional<Long> expectedVersion, Set<Option> opts) {\n        log.debug().attr(\"path\", path).attr(\"instanceId\", instanceId).log(\"storeDelete\");\n        try {\n            dbStateLock.readLock().lock();\n            if (isClosed()) {\n                return alreadyClosedFailedFuture();\n            }\n            try (Transaction transaction = db.beginTransaction(writeOptions)) {\n                byte[] pathBytes = toBytes(path);\n                byte[] oldValueData = transaction.getForUpdate(optionDontCache, pathBytes, true);\n                MetaValue metaValue = MetaValue.parse(oldValueData);\n                if (metaValue == null) {\n                    throw new MetadataStoreException.NotFoundException(String.format(\"path %s not found.\", path));\n                }\n                if (expectedVersion.isPresent() && !expectedVersion.get().equals(metaValue.getVersion())) {\n                    throw new MetadataStoreException.BadVersionException(\n                            String.format(\"Version mismatch, actual=%s, expect=%s\", metaValue.getVersion(),\n                                    expectedVersion.get()));\n                }\n                transaction.delete(pathBytes);\n                transaction.commit();\n                receivedNotification(new Notification(NotificationType.Deleted, path));\n                notifyParentChildrenChanged(path);\n                return CompletableFuture.completedFuture(null);\n            }\n        } catch (Throwable e) {\n            log.debug().attr(\"path\", path).exception(e).log(\"error in storeDelete\");\n            return FutureUtil.failedFuture(MetadataStoreException.wrap(e));\n        } finally {\n            dbStateLock.readLock().unlock();\n        }","sourceCodeStart":552,"sourceCodeEnd":588,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/RocksdbMetadataStore.java#L552-L588","documentation":"storeDelete performs a transactional read of the path and parses it as MetaValue. If no record exists under the path (null value / null parse result), it throws MetadataStoreException.NotFoundException with 'path %s not found.'. Callers using delete(path, expectedVersion-style API) hit this when deleting a key that was never created or was already deleted.","triggerScenarios":"Calling storeDelete (via MetadataStore.delete) for a path that does not exist in the RocksDB store, or that was already deleted (possibly by another instance/notification).","commonSituations":"Race between two consumers both deleting the same znode-like path; application logic assuming existence; cleanup job running twice; typo'd path.","solutions":["Check existence with store.exists(path) before deleting if absence is acceptable, and ignore NotFoundException.","Catch MetadataStoreException.NotFoundException and treat as success for idempotent delete semantics.","Log the path and verify against the producing code why the record is missing.","Use put-with-version or notifications to coordinate delete races between instances."],"exampleFix":"// before\nstore.delete(path).join();\n// after\ntry {\n    store.delete(path).join();\n} catch (CompletionException e) {\n    if (!(e.getCause() instanceof MetadataStoreException.NotFoundException)) throw e;\n    // already gone — idempotent\n}","handlingStrategy":"try-catch","validationCode":"// check existence before delete\nboolean exists = store.exists(path).get();","typeGuard":null,"tryCatchPattern":"try {\n    store.delete(path).join();\n} catch (CompletionException e) {\n    if (e.getCause() instanceof MetadataStoreException.NotFoundException) {\n        // treat as already-deleted (idempotent)\n    } else throw e;\n}","preventionTips":["Design deletes to be idempotent","Check exists() when absence is meaningful for your flow","Coordinate delete races via notifications or a single writer"],"tags":["rocksdb","not-found","delete"],"backgroundTag":"path-not-found","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"}