{"record":{"id":"489acdcba52c9727","repo":"apache/iceberg","slug":"failed-to-close-zklockfactory-for-lockid-489acd","errorCode":null,"errorMessage":"Failed to close ZkLockFactory for lockId: {}","messagePattern":"Failed to close ZkLockFactory for lockId: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/maintenance/api/ZkLockFactory.java","lineNumber":156,"sourceCode":"    } catch (Exception e) {\n      closeQuietly();\n      throw new RuntimeException(\"Failed to initialize SharedCount\", e);\n    }\n  }\n\n  private String getTaskSharePath() {\n    return LOCK_BASE_PATH + lockId + \"/task\";\n  }\n\n  private String getRecoverySharedPath() {\n    return LOCK_BASE_PATH + lockId + \"/recovery\";\n  }\n\n  private void closeQuietly() {\n    try {\n      close();\n    } catch (Exception e) {\n      LOG.warn(\"Failed to close ZkLockFactory for lockId: {}\", lockId, e);\n    }\n  }\n\n  @Override\n  public Lock createLock() {\n    return new ZkLock(getTaskSharePath(), taskSharedCount);\n  }\n\n  @Override\n  public Lock createRecoveryLock() {\n    return new ZkLock(getRecoverySharedPath(), recoverySharedCount);\n  }\n\n  @Override\n  public void close() throws IOException {\n    try {\n      if (taskSharedCount != null) {\n        taskSharedCount.close();","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/maintenance/api/ZkLockFactory.java#L138-L174","documentation":"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.","triggerScenarios":"closeQuietly() is invoked during open() failure handling and the underlying close() (releasing the Curator SharedCount / ZooKeeper resources) throws.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// verify ZK reachability before starting maintenance\n curator.getZookeeperClient().getConnectionString();","typeGuard":null,"tryCatchPattern":"try (ZkLockFactory factory = ...) { ... } catch (Exception e) { LOG.warn(\"close failed\", e); }","preventionTips":["Keep the Curator client open for the factory's lifetime","Monitor ZooKeeper session health and connectivity"],"tags":["flink","zookeeper","resource-cleanup","lock"],"backgroundTag":"resource-close-failed","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}