Skip to content

Close cached PinotDataBuffer in FilePerIndexDirectory.removeIndex() to stop mmap/heap buffer leaks#18320

Open
rsrkpatwari1234 wants to merge 3 commits intoapache:masterfrom
rsrkpatwari1234:rsrkpatwari1234-18218
Open

Close cached PinotDataBuffer in FilePerIndexDirectory.removeIndex() to stop mmap/heap buffer leaks#18320
rsrkpatwari1234 wants to merge 3 commits intoapache:masterfrom
rsrkpatwari1234:rsrkpatwari1234-18218

Conversation

@rsrkpatwari1234
Copy link
Copy Markdown
Contributor

@rsrkpatwari1234 rsrkpatwari1234 commented Apr 24, 2026

Problem

removeIndex() dropped entries from _indexBuffers but did not close the associated PinotDataBuffer. Those buffers are no longer reached by close(), so mmap (and other) mappings could stay alive until GC/finalize behavior, which is incorrect and can leak file descriptors and native memory.

Change

On removal, take the buffer out of the map, call close() on it, then run the existing cleanup (text index, vector index, or per-file delete). I/O errors while closing are surfaced as error logs.

Tests

  • Simplify testRemoveIndex so it relies on removeIndex() to release the forward buffer.
  • Add testRemoveIndexClosesReadBuffer to cover the getBuffer (read) path with the class-level PinotBuffersAfterMethodCheckRule leak check.

Scope note

Text- and vector-specific cleanup still runs after the buffer is released, so we do not keep stale mapped buffers over directory deletes.

Fixes #18218

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 24, 2026

Codecov Report

❌ Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.43%. Comparing base (ab9ac39) to head (dba5ad2).
⚠️ Report is 31 commits behind head on master.

Files with missing lines Patch % Lines
...ent/local/segment/store/FilePerIndexDirectory.java 75.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #18320      +/-   ##
============================================
- Coverage     63.61%   63.43%   -0.18%     
- Complexity     1659     1683      +24     
============================================
  Files          3246     3253       +7     
  Lines        197514   198809    +1295     
  Branches      30578    30787     +209     
============================================
+ Hits         125656   126124     +468     
- Misses        61813    62619     +806     
- Partials      10045    10066      +21     
Flag Coverage Δ
custom-integration1 100.00% <ø> (ø)
integration 100.00% <ø> (ø)
integration1 100.00% <ø> (ø)
integration2 0.00% <ø> (ø)
java-11 ?
java-21 63.43% <75.00%> (-0.15%) ⬇️
temurin 63.43% <75.00%> (-0.18%) ⬇️
unittests 63.43% <75.00%> (-0.18%) ⬇️
unittests1 55.36% <12.50%> (-0.23%) ⬇️
unittests2 35.00% <75.00%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Close the FilePerIndexDirectory.removeIndex() buffer leak

3 participants