{"record":{"id":"30142249e5721b39","repo":"apache/dolphinscheduler","slug":"zookeeper-get-children-error","errorCode":null,"errorMessage":"zookeeper get children error","messagePattern":"zookeeper get children error","errorType":"exception","errorClass":"RegistryException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-zookeeper/src/main/java/org/apache/dolphinscheduler/plugin/registry/zookeeper/ZookeeperRegistry.java","lineNumber":193,"sourceCode":"        try {\n            client.create()\n                    .orSetData()\n                    .creatingParentsIfNeeded()\n                    .withMode(mode)\n                    .forPath(key, value.getBytes(StandardCharsets.UTF_8));\n        } catch (Exception e) {\n            throw new RegistryException(\"Failed to put registry key: \" + key, e);\n        }\n    }\n\n    @Override\n    public List<String> children(String key) {\n        try {\n            List<String> result = client.getChildren().forPath(key);\n            result.sort(Comparator.reverseOrder());\n            return result;\n        } catch (Exception e) {\n            throw new RegistryException(\"zookeeper get children error\", e);\n        }\n    }\n\n    @Override\n    public void delete(String nodePath) {\n        try {\n            client.delete()\n                    .deletingChildrenIfNeeded()\n                    .forPath(nodePath);\n        } catch (KeeperException.NoNodeException ignored) {\n            // Is already deleted or does not exist\n        } catch (Exception e) {\n            throw new RegistryException(\"Failed to delete registry key: \" + nodePath, e);\n        }\n    }\n\n    @Override\n    public boolean acquireLock(String key) {","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-zookeeper/src/main/java/org/apache/dolphinscheduler/plugin/registry/zookeeper/ZookeeperRegistry.java#L175-L211","documentation":"ZookeeperRegistry.children() lists the child znodes of a key via client.getChildren().forPath(key), sorts them in reverse order, and wraps any failure in a RegistryException 'zookeeper get children error'. A missing parent key (NoNode) is the most common cause; connection loss and ACL denial also surface here.","triggerScenarios":"Calling children(key) when the key has no znode (KeeperException.NoNode), when the session is expired/unreachable, when ACLs deny listing children, or when the key is a malformed path.","commonSituations":"Enumerating tasks/masters under a parent path that was concurrently deleted (failover, cleanup job); querying before the parent was ever created; ZooKeeper unreachable during startup; path prefix mismatch after changing the registry root config.","solutions":["Guard with registry.exists(key) before listing children, and treat a missing parent as an empty result","Check the wrapped cause code: NoNode → create the parent or handle as empty list; CONNECTIONLOSS → retry after session recovery","Verify both writer and reader use the same registry root/prefix configuration","Confirm ACLs permit the client to list the parent znode"],"exampleFix":"// before\nList<String> kids = registry.children(\"/tasks/\" + groupId);\n// after\nList<String> kids = registry.exists(\"/tasks/\" + groupId)\n        ? registry.children(\"/tasks/\" + groupId)\n        : Collections.emptyList();","handlingStrategy":"validation","validationCode":"if (!registry.exists(key)) {\n    return Collections.emptyList(); // parent never created or concurrently deleted\n}\nList<String> children = registry.children(key);","typeGuard":null,"tryCatchPattern":"try {\n    return registry.children(key);\n} catch (RegistryException e) {\n    if (e.getCause() instanceof KeeperException.NoNodeException) {\n        return Collections.emptyList();\n    }\n    throw e;\n}","preventionTips":["Create parent znodes (persistent) before children are expected to exist","Treat empty/missing parents as normal states in failover and cleanup paths","Keep the registry root prefix consistent between components that create and enumerate nodes","Retry children() on transient connection-loss causes rather than failing the whole listing"],"tags":["zookeeper","curator","registry","list-children"],"backgroundTag":"resource-not-found","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}