thecoop opened a new issue, #14930:
URL: https://github.com/apache/lucene/issues/14930

   ### Description
   
   Following on from 
https://github.com/apache/lucene/pull/14844#discussion_r2168818779, there are 
cases where `IndexWriter.merge` does not close merge instances before closing 
the 'root' readers, leading to the necessity of the extra check in 
`AssertingKnnVectorsReader.close`.
   
   In particular, 
[SegmentMerger](https://github.com/apache/lucene/blob/f7e7c9fb271a009f9da3e3b40f2b50e421d92a2d/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java#L5213)
 (which creates the merge reader instances) is not cleaned up if an [exception 
is thrown 
later](https://github.com/apache/lucene/blob/f7e7c9fb271a009f9da3e3b40f2b50e421d92a2d/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java#L5222),
 which is where the original problem was found. There may of course be more 
instances elsewhere.
   
   Currently, there's some ambiguity in the role of merge reader instances - 
are they clones? Do they have their own independent lifecycle? Are they 
dependent on their 'parent' reader at all? They were just clones, but the 
introduction of `finishMerge` introduces a lifecycle that is not quite 
independent - add on top of the restrictions around how [ReadAdvice needs to be 
managed](https://github.com/apache/lucene/pull/14844).
   
   I think the way to solve this is to make merge instances properly closeable 
by replacing `finishMerge` with a full `close` implementation, with their own 
independent lifecycle. `SegmentMerger` would then be closeable, as part of 
tidying up after an exception during merging. Most readers wouldn't actually 
need the independence given to them, but it's better to be more permissive in 
what merge readers are, which can be ignored by most implementations, than less 
permissive, leading to lifecycle issues when a merge reader can't do what it 
needs to by its implementation.
   
   ### Version and environment details
   
   _No response_


-- 
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: issues-unsubscr...@lucene.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to