Jackie-Jiang opened a new pull request, #19175:
URL: https://github.com/apache/pinot/pull/19175

   ## Summary
   
   Fixes resource-handling issues in the Lucene HNSW vector index paths.
   
   ### `IndexWriter` does not close the `Directory` passed to it
   
   Lucene keeps the caller-supplied `Directory` as `directoryOrig` and, on 
close, releases only the write lock, the reader pool and the deleter — 
ownership of the directory stays with the caller. Two places assumed otherwise:
   
   - `MutableVectorIndex` constructor closed *either* the writer *or* the 
directory (`if` / `else if`). When `IndexWriter` construction succeeded and the 
following `commit()` threw, the `FSDirectory` was left open.
   - `HnswVectorIndexCreator.close()` closed the writer and the directory as 
separate statements, so a throw from `_indexWriter.close()` skipped the 
directory entirely.
   
   Both now close writer-then-directory through `IOUtils.close`, which closes 
every argument even when an earlier one throws (first exception propagates, the 
rest are suppressed). `MutableVectorIndex.close()` additionally cleans up when 
the explicit `commit()` preceding the close throws, since that skips the close 
call altogether.
   
   ### `MutableVectorIndex` deleted other columns' indexes
   
   `_indexDir` was `<tmp>/<segmentName>` — per segment — while the Lucene 
directory beneath it is per column. One `MutableVectorIndex` is created per 
(segment, column), so `close()` recursively deleted the still-open directories 
of every other vector column of the same segment, and a construction failure 
for one column did the same.
   
   `_indexDir` now refers to the per-column directory. The per-segment parent 
is removed with a plain `File.delete()`, which succeeds only once it is empty — 
i.e. exactly when the last column has released its index — so empty directories 
do not accumulate in temp. The on-disk layout is unchanged; only the deletion 
scope moved down one level.
   


-- 
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]


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

Reply via email to