ayinresh commented on issue #15068: URL: https://github.com/apache/lucene/issues/15068#issuecomment-3211517180
Hi @uschindler, Thank you for opening the issue! Yes this is custom usage of Lucene (not opensearch/ES). We do call [ReferenceManager::close](https://github.com/apache/lucene/blob/b1c1770e8052a74fd30e3520e4fd662e2724bd1c/lucene/core/src/java/org/apache/lucene/search/ReferenceManager.java#L134) while it is in use by other threads, but the API indicates that this is safe: ``` /** * Closes this ReferenceManager to prevent future {@link #acquire() acquiring}. A reference * manager should be closed if the reference to the managed resource should be disposed or the * application using the {@link ReferenceManager} is shutting down. The managed resource might not * be released immediately, if the {@link ReferenceManager} user is holding on to a previously * {@link #acquire() acquired} reference. The resource will be released once when the last * reference is {@link #release(Object) released}. Those references can still be used as if the * manager was still active. * * <p>Applications should not {@link #acquire() acquire} new references from this manager once * this method has been called. {@link #acquire() Acquiring} a resource on a closed {@link * ReferenceManager} will throw an {@link AlreadyClosedException}. * * @throws IOException if the underlying reader of the current reference could not be closed */ ``` Based on that documentation we do the following (which we believed was safe): - A single background thread indexes documents and periodically creates a new NRT `SearcherManager` - Query threads acquire the `SearcherManager` and can hold it for extended periods of time - When the background thread decides that the `SearcherManager` should expire, it calls `SearcherManager::close`. The expectation is that the last query thread to release the `SearcherManager` will actually be the one to execute [doClose](https://github.com/apache/lucene/blob/cb16075c5fd5c4bbcb0fab561e185fe2e3f8e939/lucene/core/src/java/org/apache/lucene/index/IndexReader.java#L224) - [It might seem strange that we don't just use `maybeRefresh`, but we implement point in time search and need to keep multiple searchers around for long periods of time] -- 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 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