{"record":{"id":"215188c4420f506c","repo":"apache/druid","slug":"unannouncing-non-empty-path-s","errorCode":null,"errorMessage":"Unannouncing non-empty path[%s]","messagePattern":"Unannouncing non-empty path\\[(.+?)\\]","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"server/src/main/java/org/apache/druid/curator/announcement/NodeAnnouncer.java","lineNumber":368,"sourceCode":"      final byte[] value = announcedPaths.remove(path);\n\n      if (value == null) {\n        log.debug(\"Path[%s] not announced, cannot unannounce.\", path);\n        return;\n      }\n    }\n\n    log.info(\"unannouncing [%s]\", path);\n\n    try {\n      CuratorOp deleteOp = curator.transactionOp().delete().forPath(path);\n      curator.transaction().forOperations(deleteOp);\n    }\n    catch (KeeperException.NoNodeException e) {\n      log.info(\"Unannounced node[%s] that does not exist.\", path);\n    }\n    catch (KeeperException.NotEmptyException e) {\n      log.warn(\"Unannouncing non-empty path[%s]\", path);\n    }\n    catch (Exception e) {\n      throw new RuntimeException(e);\n    }\n  }\n\n  private void startCache(CuratorCache cache)\n  {\n    try {\n      cache.start();\n    }\n    catch (Throwable e) {\n      throw CloseableUtils.closeAndWrapInCatch(e, cache);\n    }\n  }\n\n  @GuardedBy(\"toAnnounce\")\n  private void createPath(String parentPath, boolean removeParentsIfCreated)","sourceCodeStart":350,"sourceCodeEnd":386,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/server/src/main/java/org/apache/druid/curator/announcement/NodeAnnouncer.java#L350-L386","documentation":"In NodeAnnouncer.unannounce, after a successful ZK delete transaction, a subsequent transactional delete of the parent path failed with KeeperException.NotEmptyException, meaning the parent znode still holds child znodes. The library logs a warning instead of failing because partial cleanup of a non-empty path is usually benign (other announcements still live there).","triggerScenarios":"Calling unannounce(path) (via closeResources) when the znode at `path` has children — e.g. the announced node also created child znodes, or multiple announcers share a parent path and only some were unannounced before the parent delete was attempted.","commonSituations":"Shared ZK paths (e.g. multiple processes or multiple announcements under one parent directory), abrupt shutdown where children were created after the initial announcement, or stale hierarchy left from a previous run that wasn't fully cleaned up.","solutions":["Ensure the full announcement subtree is deleted: call unannounce on the exact paths created by announce, and only delete parent nodes you own.","Check for other announcements/children under the path with the ZK CLI (zkCli.sh ls /path) before assuming cleanup failure is a bug.","If this is a graceful shutdown, verify the CuratorFramework and NodeAnnouncer are closed in the correct order so child unannouncements complete first.","If the path is stale garbage, remove it manually with the ZK CLI after confirming no live processes depend on it."],"exampleFix":"// before\nannouncer.unannounce(\"/druid/cluster/coordinator\"); // deletes only the parent, children remain\n// after\nannouncer.unannounce(\"/druid/cluster/coordinator/instance1\"); // delete leaf znodes first\nannouncer.unannounce(\"/druid/cluster/coordinator\"); // then the parent","handlingStrategy":"validation","validationCode":"// ensure only leaf znodes this process created are unannounced\nif (zooKeeper.getChildren(path, false).isEmpty()) {\n  announcer.unannounce(path);\n} else {\n  // unannounce children first or skip parent delete\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Unannounce the exact leaf paths created by announce, never a shared parent you don't own.","Order lifecycle shutdown so all child announcements are removed before parent cleanup.","Audit shared ZK paths across services to avoid overlapping announcements."],"tags":["zookeeper","curator","cleanup","announcement"],"backgroundTag":"resource-not-found","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}