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

Jackie-Jiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new 4863cdcd821 fix(segment): close removed PinotDataBuffer in 
FilePerIndexDirectory (#18405)
4863cdcd821 is described below

commit 4863cdcd821ea85b88cdd6ba7fc10c34679724e3
Author: Deepak kumar <[email protected]>
AuthorDate: Thu May 7 16:03:18 2026 -0700

    fix(segment): close removed PinotDataBuffer in FilePerIndexDirectory 
(#18405)
---
 .../local/segment/store/FilePerIndexDirectory.java       | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git 
a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/store/FilePerIndexDirectory.java
 
b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/store/FilePerIndexDirectory.java
index fe05e2e4960..a597ef1aabc 100644
--- 
a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/store/FilePerIndexDirectory.java
+++ 
b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/segment/store/FilePerIndexDirectory.java
@@ -99,8 +99,20 @@ class FilePerIndexDirectory extends ColumnIndexDirectory {
 
   @Override
   public void removeIndex(String columnName, IndexType<?, ?, ?> indexType) {
-    // TODO: this leaks the removed data buffer (it's not going to be freed in 
close() method)
-    _indexBuffers.remove(new IndexKey(columnName, indexType));
+    IndexKey key = new IndexKey(columnName, indexType);
+    // Fetch the buffer without removing it from the map first; the mapping is 
removed only after close() succeeds.
+    // If close() throws, the entry stays in _indexBuffers so a subsequent 
directory close() can attempt to release
+    // it on a best-effort basis (this class is not thread-safe; callers must 
serialize access).
+    PinotDataBuffer buffer = _indexBuffers.get(key);
+    if (buffer != null) {
+      try {
+        buffer.close();
+        _indexBuffers.remove(key);
+      } catch (Exception e) {
+        throw new RuntimeException(
+            String.format("Failed to close index buffer for column: %s, 
indexType: %s", columnName, indexType), e);
+      }
+    }
     if (indexType == StandardIndexes.text()) {
       TextIndexUtils.cleanupTextIndex(_segmentDirectory, columnName);
     } else if (indexType == StandardIndexes.vector()) {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to