MrFlap opened a new pull request, #15952:
URL: https://github.com/apache/lucene/pull/15952

   Resolves https://github.com/apache/lucene/issues/15935
   
   ### Problem
   `PerFieldKnnVectorsFormat` subclasses that allocate merge-time resources 
(such as thread pools for concurrent HNSW graph construction) have no way to 
know when a merge completes. `getKnnVectorsFormatForField` is called per-field 
during merge, but there is no corresponding callback when the merge finishes. 
This makes it impossible to cleanly release per-merge resources, leading to 
resource leaks.
   
   ### Solution
   Add a `protected void afterMerge() throws IOException` method with a no-op 
default to both `KnnVectorsWriter` and `PerFieldKnnVectorsFormat`.
   
   A consumer can then override `afterMerge()` to shrink a shared thread pool 
after each merge completes, ensuring the pool scales elastically with the 
number of concurrent merges rather than leaking threads indefinitely.
   
   ### Changes
   `KnnVectorsWriter.java`: Added `afterMerge()` no-op method. Wrapped the 
field merge loop in `merge()` with `try`/`finally { afterMerge() }`.
   `PerFieldKnnVectorsFormat.java`: Added `afterMerge()` no-op method on the 
format. `FieldsWriter` overrides `afterMerge()` to delegate to 
`PerFieldKnnVectorsFormat.this.afterMerge()`.
   
   cc @navneet1v @shatejas 


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