apache/iceberg · warning
Failed to close ZkLockFactory for lockId
Error message
Failed to close ZkLockFactory for lockId: {} What it means
ZkLockFactory.closeQuietly logs a warning when closing the ZooKeeper-based lock factory (which calls close()) throws an Exception. The exception is swallowed so that close during open-failure cleanup does not mask the original error.
Solutions
- Check the logged stack trace for the underlying Curator/ZooKeeper exception (usually session expiry or connection loss)
- Verify ZooKeeper connectivity and session timeout settings
- Ensure the CuratorFramework client is started and not closed before the lock factory
Defensive patterns
Strategy: try-catch
Validate before calling
// verify ZK reachability before starting maintenance curator.getZookeeperClient().getConnectionString();
Try / catch
try (ZkLockFactory factory = ...) { ... } catch (Exception e) { LOG.warn("close failed", e); } Prevention
- Keep the Curator client open for the factory's lifetime
- Monitor ZooKeeper session health and connectivity
When it happens
Trigger: closeQuietly() is invoked during open() failure handling and the underlying close() (releasing the Curator SharedCount / ZooKeeper resources) throws.
Common situations: ZooKeeper session already expired or disconnected when the factory is being closed; Curator client already closed; initialization failed partway leaving resources in a bad state.
Related errors
- Failed to close ZkLockFactory for lockId
- Connection to Zookeeper timed out
- Connection to Zookeeper timed out
- Failed to acquire Zookeeper lock
- Failed to acquire Zookeeper lock
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/489acdcba52c9727.
Report an issue: GitHub.
Appendix: source
Thrown at flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/maintenance/api/ZkLockFactory.java:156
} catch (Exception e) {
closeQuietly();
throw new RuntimeException("Failed to initialize SharedCount", e);
}
}
private String getTaskSharePath() {
return LOCK_BASE_PATH + lockId + "/task";
}
private String getRecoverySharedPath() {
return LOCK_BASE_PATH + lockId + "/recovery";
}
private void closeQuietly() {
try {
close();
} catch (Exception e) {
LOG.warn("Failed to close ZkLockFactory for lockId: {}", lockId, e);
}
}
@Override
public Lock createLock() {
return new ZkLock(getTaskSharePath(), taskSharedCount);
}
@Override
public Lock createRecoveryLock() {
return new ZkLock(getRecoverySharedPath(), recoverySharedCount);
}
@Override
public void close() throws IOException {
try {
if (taskSharedCount != null) {
taskSharedCount.close();View on GitHub (pinned to 86d9c8fc54)