hudi-agent commented on code in PR #18834:
URL: https://github.com/apache/hudi/pull/18834#discussion_r3336085965


##########
hudi-common/src/main/java/org/apache/hudi/common/table/view/SpillableMapBasedFileSystemView.java:
##########
@@ -225,14 +225,18 @@ protected void 
removeReplacedFileIdsAtInstants(Set<String> instants) {
   }
 
   @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();

Review Comment:
   🤖 I think moving `super.closeResources()` to the top here may have broken 
the cleanup path. `HoodieTableFileSystemView.closeResources()` sets 
`partitionToFileGroupsMap`, `fgIdToPendingCompaction`, 
`fgIdToPendingLogCompaction`, `fgIdToBootstrapBaseFile`, 
`fgIdToReplaceInstants`, and `fgIdToPendingClustering` to null. After that 
runs, the subsequent `closeFileGroupsMapIfPresent()` / 
`closePendingClusteringMapIfPresent()` / etc. calls all see a null field and 
skip the `ExternalSpillableMap.close()` call — so the disk-backed maps (and any 
RocksDB handles inside them) are never released. Could we put 
`super.closeResources()` back at the end so the spillable maps actually get 
closed before the references are dropped?
   
   <sub><i>- AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to