{"record":{"id":"e708db5f1fe71a1c","repo":"apache/iceberg","slug":"failed-to-release-lock-on-file-with-owner","errorCode":null,"errorMessage":"Failed to release lock on file: {} with owner: {}","messagePattern":"Failed to release lock on file: (.+?) with owner: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"core/src/main/java/org/apache/iceberg/hadoop/HadoopTableOperations.java","lineNumber":398,"sourceCode":"        CommitFailedException cfe =\n            new CommitFailedException(\"Failed to commit changes using rename: %s\", dst);\n        RuntimeException re = tryDelete(src);\n        if (re != null) {\n          cfe.addSuppressed(re);\n        }\n        throw cfe;\n      }\n    } catch (IOException e) {\n      CommitFailedException cfe =\n          new CommitFailedException(e, \"Failed to commit changes using rename: %s\", dst);\n      RuntimeException re = tryDelete(src);\n      if (re != null) {\n        cfe.addSuppressed(re);\n      }\n      throw cfe;\n    } finally {\n      if (!lockManager.release(dst.toString(), src.toString())) {\n        LOG.warn(\"Failed to release lock on file: {} with owner: {}\", dst, src);\n      }\n    }\n  }\n\n  /**\n   * Deletes the file from the file system. Any RuntimeException will be caught and returned.\n   *\n   * @param path the file to be deleted.\n   * @return RuntimeException caught, if any. null otherwise.\n   */\n  private RuntimeException tryDelete(Path path) {\n    try {\n      io().deleteFile(path.toString());\n      return null;\n    } catch (RuntimeException re) {\n      return re;\n    }\n  }","sourceCodeStart":380,"sourceCodeEnd":416,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/hadoop/HadoopTableOperations.java#L380-L416","documentation":"During renameToFinal(), HadoopTableOperations commits a new metadata file by locking the destination, writing, then renaming. If the lock is not successfully released in the finally block (lockManager.release returns false), this warning is logged. The commit itself already succeeded or failed; the risk is a stale lock that can block future commits until it expires.","triggerScenarios":"commit() -> renameToFinal() where lockManager.release(dst, src) returns false — e.g. the lock owner token no longer matches, lock state was corrupted, or the underlying lock store operation silently failed while returning false.","commonSituations":"Long-running commits that exceeded lock TTL so ownership lapsed; duplicated writer processes using mismatched lock owner configuration; stale locks left by crashed previous runs interfering with release bookkeeping.","solutions":["Inspect the lock store for a stale lock on the destination metadata file and remove it manually","Verify all writers use identical lock manager configuration (e.g. same lock table settings)","Reduce commit duration or increase lock TTL/expiry","Ensure no two jobs write to the same table concurrently with different owner settings","Retry the commit once the lock has expired"],"exampleFix":"// before (mismatched owners across jobs)\nconf.set(\"lock.owner\", \"job-a\")  // other jobs use job-b owner\n// after\nconf.set(\"iceberg.lock.owner\", CLUSTER_WIDE_OWNER_ID)  // consistent for all writers","handlingStrategy":"retry","validationCode":"// before committing, ensure no stale lock exists on the metadata path\nif (lockStore.hasActiveLock(dstPath)) {\n  throw new IllegalStateException(\"stale lock on \" + dstPath);\n}","typeGuard":null,"tryCatchPattern":"try {\n  table.fastAppend().commit();\n} catch (CommitFailedException e) {\n  // a stale lock blocked the commit; clear lock store and retry with backoff\n}","preventionTips":["Use identical lock manager config across all writer jobs","Set lock TTL comfortably above max commit duration","Periodically garbage-collect stale locks from the lock store","Avoid running two independent jobs writing the same table without catalog-level locking"],"tags":["hadoop","locking","commit","concurrency"],"backgroundTag":"internal-invariant-violation","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}