You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by da...@apache.org on 2026/04/21 02:21:11 UTC

(hudi) branch master updated: fix: HoodieStorage resource leak in FileSystemBasedLockProvider.close() (#18461)

This is an automated email from the ASF dual-hosted git repository.

danny0405 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hudi.git


The following commit(s) were added to refs/heads/master by this push:
     new adf29acc2edf fix: HoodieStorage resource leak in FileSystemBasedLockProvider.close() (#18461)
adf29acc2edf is described below

commit adf29acc2edf4d30ce55366b5c49ad28bc5c6a31
Author: mailtoboggavarapu-coder <ma...@gmail.com>
AuthorDate: Mon Apr 20 22:21:04 2026 -0400

    fix: HoodieStorage resource leak in FileSystemBasedLockProvider.close() (#18461)
    
    * fix: close HoodieStorage resource in FileSystemBasedLockProvider.close()
    
    Adds a finally block to properly close the HoodieStorage instance
    after the lock file is deleted, preventing resource leaks.
    
    Fixes #14922
    
    * fix: simplify log message per review feedback
    
    Addresses nit from @yihua: shorten log to "Failed to close HoodieStorage" since logger already includes class context.
    
    * fix: add comment explaining HoodieStorage.close() is no-op for HadoopStorage
    
    Addresses review feedback from danny0405: HoodieHadoopStorage.close() is
    a no-op because Hadoop FileSystem instances are shared within the JVM
    process lifecycle. Added a comment to explain this behavior and why the
    call is still retained for interface contract correctness.
---
 .../client/transaction/lock/FileSystemBasedLockProvider.java  | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/transaction/lock/FileSystemBasedLockProvider.java b/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/transaction/lock/FileSystemBasedLockProvider.java
index 18186476aba7..fa7fde517508 100644
--- a/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/transaction/lock/FileSystemBasedLockProvider.java
+++ b/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/transaction/lock/FileSystemBasedLockProvider.java
@@ -103,6 +103,17 @@ public class FileSystemBasedLockProvider implements LockProvider<String>, Serial
         storage.deleteFile(this.lockFile);
       } catch (IOException e) {
         throw new HoodieLockException(generateLogStatement(LockState.FAILED_TO_RELEASE), e);
+      } finally {
+        try {
+          // HoodieHadoopStorage.close() is currently a no-op since Hadoop FileSystem
+          // instances are shared within the JVM process lifecycle and cannot be
+          // individually closed. This call is retained for HoodieStorage interface
+          // contract correctness and to support future storage backends that may
+          // implement close().
+          storage.close();
+        } catch (IOException closeEx) {
+          log.warn("Failed to close HoodieStorage", closeEx);
+        }
       }
     }
   }