You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by vh...@apache.org on 2026/08/05 10:45:03 UTC
(hudi) 02/13: fix: Fix NPE due to race condition while handling rocksdb handles (#18834)
This is an automated email from the ASF dual-hosted git repository.
voonhous pushed a commit to branch release-1.2.1
in repository https://gitbox.apache.org/repos/asf/hudi.git
commit 6a65c1efd2c2df0e6556f15cb77721f4cb8cef3c
Author: Lokesh Jain <lj...@apache.org>
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 <lj...@192.168.1.148>
Co-authored-by: Lokesh Jain <lj...@Lokeshs-MacBook-Pro.local>
Co-authored-by: Lokesh Jain <lj...@192.168.1.8>
(cherry picked from commit 8259182e7e3256d7b44263bb416ae77a848873b5)
---
.../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() {