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


##########
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, ...).
     closeFileGroupsMapIfPresent();
     closePendingClusteringMapIfPresent();
     closePendingCompactionMapIfPresent();
     closePendingLogCompactionMapIfPresent();
     closeBootstrapFileMapIfPresent();
     closeReplaceInstantsMapIfPresent();
-    super.close();
+    super.closeResources();

Review Comment:
   🤖 Since `SpillableMapBasedFileSystemView` no longer overrides `close()`, the 
actual closer is now `HoodieTableFileSystemView.close()`, which sets the map 
references to `null` and `this.closed = true` **after** `super.close()` returns 
(i.e. outside the writeLock). A reader arriving in that brief window can still 
acquire the readLock, observe `isClosed()==false` (no happens-before for the 
post-`super.close()` writes), and call `put()` on a still-referenced spillable 
map whose underlying RocksDB handles were just released under the writeLock — 
same NPE as the bug being fixed, just a narrower window. Would it make sense to 
move that `closed=true` / null-out work into 
`HoodieTableFileSystemView.closeResources()` as well so it runs under the same 
writeLock? @nsivabalan
   
   <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