apache/dolphinscheduler · error · RegistryException
zookeeper check key is existed error
Error message
zookeeper check key is existed error
What it means
ZookeeperRegistry.exists() calls Curator's client.checkExists().forPath(key) and wraps any exception in a RegistryException with message 'zookeeper check key is existed error'. Unlike get(), a missing node is not an error here (null Stat is returned as false); the wrapper fires only on infrastructure or argument failures.
Source
Thrown at dolphinscheduler-registry/dolphinscheduler-registry-plugins/dolphinscheduler-registry-zookeeper/src/main/java/org/apache/dolphinscheduler/plugin/registry/zookeeper/ZookeeperRegistry.java:167
throw new RegistryException("Failed to subscribe listener for key: " + path, e);
}
}
@Override
public String get(String key) {
try {
return new String(client.getData().forPath(key), StandardCharsets.UTF_8);
} catch (Exception e) {
throw new RegistryException("zookeeper get data error", e);
}
}
@Override
public boolean exists(String key) {
try {
return null != client.checkExists().forPath(key);
} catch (Exception e) {
throw new RegistryException("zookeeper check key is existed error", e);
}
}
@Override
public void put(String key, String value, boolean deleteOnDisconnect) {
final CreateMode mode = deleteOnDisconnect ? CreateMode.EPHEMERAL : CreateMode.PERSISTENT;
try {
client.create()
.orSetData()
.creatingParentsIfNeeded()
.withMode(mode)
.forPath(key, value.getBytes(StandardCharsets.UTF_8));
} catch (Exception e) {
throw new RegistryException("Failed to put registry key: " + key, e);
}
}
View on GitHub (pinned to 02eac45a1b)
Solutions
- Check the wrapped cause: KeeperException.Code CONNECTIONLOSS/SESSIONEXPIRED → verify ensemble health and wait for Curator session recovery, then retry
- Validate the key is an absolute, well-formed ZNode path before calling
- Verify registry.zookeeper.connect-string, chroot, and auth configuration in the DolphinScheduler common properties
- Check ZooKeeper server logs and ACLs if AUTHFAILED/NOAUTH appears
Example fix
// before
String key = "/ds/" + id;
boolean ok = registry.exists(key);
// after
if (id == null || id.isEmpty()) { throw new IllegalArgumentException("id required"); }
boolean ok = registry.exists("/ds/" + id); Defensive patterns
Strategy: try-catch
Validate before calling
if (key == null || !key.startsWith("/")) {
throw new IllegalArgumentException("registry key must be an absolute znode path");
} Try / catch
try {
return registry.exists(key);
} catch (RegistryException e) {
Throwable cause = e.getCause();
if (cause instanceof KeeperException.ConnectionLossException || cause instanceof KeeperException.SessionExpiredException) {
return retryExists(key); // retry after session recovery
}
throw e;
} Prevention
- Validate path format before any registry call
- Check ZooKeeper availability during health checks so infra failures are detected early
- Watch the cause exception, not just the RegistryException wrapper
- Keep chroot and path-prefix config aligned across components
When it happens
Trigger: Calling exists(key) while the ZooKeeper session is expired or the ensemble is unreachable (CONNECTIONLOSS), when the key is a malformed path (empty string, not starting with '/', contains null byte — BADARGUMENTS), or when ACLs deny the checkExists stat call.
Common situations: ZooKeeper cluster down or network partition during startup health checks; building keys from user-supplied IDs that produce invalid paths; misconfigured chroot or connect string so all paths resolve outside the allowed tree.
Understand the failure class
Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.
Related errors
- Failed to subscribe listener for key:
- zookeeper get data error
- Failed to put registry key:
- zookeeper get children error
- Worker registry client start up error
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/9b19e91646867472.
Report an issue: GitHub.