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

nsivabalan 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 8259182e7e32 fix: Fix NPE due to race condition while handling rocksdb 
handles (#18834)
8259182e7e32 is described below

commit 8259182e7e3256d7b44263bb416ae77a848873b5
Author: Lokesh Jain <[email protected]>
AuthorDate: Tue Jun 2 05:15:53 2026 +0530

    fix: Fix NPE due to race condition while handling rocksdb handles (#18834)
    
    
    
    ---------
    
    Co-authored-by: Lokesh Jain <[email protected]>
    Co-authored-by: Lokesh Jain <[email protected]>
    Co-authored-by: Lokesh Jain <[email protected]>
---
 .../apache/hudi/common/table/view/HoodieTableFileSystemView.java | 9 +++++++--
 .../hudi/common/table/view/RocksDbBasedFileSystemView.java       | 3 +++
 .../hudi/common/table/view/SpillableMapBasedFileSystemView.java  | 8 ++++++--
 3 files changed, 16 insertions(+), 4 deletions(-)

diff --git 
a/hudi-common/src/main/java/org/apache/hudi/common/table/view/HoodieTableFileSystemView.java
 
b/hudi-common/src/main/java/org/apache/hudi/common/table/view/HoodieTableFileSystemView.java
index 70f81ffa4cee..10d8879f8233 100644
--- 
a/hudi-common/src/main/java/org/apache/hudi/common/table/view/HoodieTableFileSystemView.java
+++ 
b/hudi-common/src/main/java/org/apache/hudi/common/table/view/HoodieTableFileSystemView.java
@@ -438,8 +438,8 @@ public class HoodieTableFileSystemView extends 
IncrementalTimelineSyncFileSystem
   }
 
   @Override
-  public void close() {
-    super.close();
+  protected void closeResources() throws Exception {
+    super.closeResources();
     this.fgIdToPendingCompaction = null;
     this.fgIdToPendingLogCompaction = null;
     this.partitionToFileGroupsMap = null;
@@ -449,6 +449,11 @@ public class HoodieTableFileSystemView extends 
IncrementalTimelineSyncFileSystem
     this.closed = true;
   }
 
+  @Override
+  public void close() {
+    super.close();
+  }
+
   @Override
   public boolean isClosed() {
     return closed;
diff --git 
a/hudi-common/src/main/java/org/apache/hudi/common/table/view/RocksDbBasedFileSystemView.java
 
b/hudi-common/src/main/java/org/apache/hudi/common/table/view/RocksDbBasedFileSystemView.java
index c2cac1420ff3..2620a29784fc 100644
--- 
a/hudi-common/src/main/java/org/apache/hudi/common/table/view/RocksDbBasedFileSystemView.java
+++ 
b/hudi-common/src/main/java/org/apache/hudi/common/table/view/RocksDbBasedFileSystemView.java
@@ -598,6 +598,7 @@ public class RocksDbBasedFileSystemView extends 
IncrementalTimelineSyncFileSyste
   @Override
   public void close() {
     try {
+      writeLock.lock();
       LOG.info("Closing Rocksdb !!");
       closed = true;
       closeResources();
@@ -605,6 +606,8 @@ public class RocksDbBasedFileSystemView extends 
IncrementalTimelineSyncFileSyste
       LOG.info("Closed Rocksdb !!");
     } catch (Exception e) {
       throw new HoodieException("Unable to close file system view", e);
+    } finally {
+      writeLock.unlock();
     }
   }
 
diff --git 
a/hudi-common/src/main/java/org/apache/hudi/common/table/view/SpillableMapBasedFileSystemView.java
 
b/hudi-common/src/main/java/org/apache/hudi/common/table/view/SpillableMapBasedFileSystemView.java
index 89687ef07057..f531907653b1 100644
--- 
a/hudi-common/src/main/java/org/apache/hudi/common/table/view/SpillableMapBasedFileSystemView.java
+++ 
b/hudi-common/src/main/java/org/apache/hudi/common/table/view/SpillableMapBasedFileSystemView.java
@@ -225,14 +225,18 @@ public class SpillableMapBasedFileSystemView extends 
HoodieTableFileSystemView {
   }
 
   @Override
-  public void close() {
+  protected void closeResources() throws Exception {
+    // Close ExternalSpillableMaps (which hold RocksDB handles) while the 
writeLock is held
+    // by AbstractTableFileSystemView.close(). This prevents a race where a 
concurrent reader
+    // holding readLock could be mid-call in RocksDBDAO.put() when the handles 
are cleared,
+    // causing a NullPointerException at RocksDB.put(null_handle, ...).
+    super.closeResources();
     closeFileGroupsMapIfPresent();
     closePendingClusteringMapIfPresent();
     closePendingCompactionMapIfPresent();
     closePendingLogCompactionMapIfPresent();
     closeBootstrapFileMapIfPresent();
     closeReplaceInstantsMapIfPresent();
-    super.close();
   }
 
   private void closeReplaceInstantsMapIfPresent() {

Reply via email to