On 3/14/2017 3:08 AM, Gerald Reinhart wrote:
> Hi,
>    The custom code we have is something like this :
> public class MySearchHandlerextends SearchHandler {
> @Override public void handleRequestBody(SolrQueryRequest req,
> SolrQueryResponse rsp)throws Exception {
>         SolrIndexSearcher  searcher =req.getSearcher();
>         try{
>                  // Do stuff with the searcher....
>         }finally {
>             req.close();
>         }
<snip>
>      Despite the fact that we always close the request each time we get
> a SolrIndexSearcher from the request, the number of SolrIndexSearcher
> instances is increasing. Each time a new commit is done on the index, a
> new Searcher is created (this is normal) but the old one remains.     Is
> there something wrong with this custom code ?

My understanding of Solr and Lucene internals is rudimentary, but I
might know what's happening here.

The code closes the request, but never closes the searcher.  Searcher
objects include a Lucene object that holds onto the index files that
pertain to that view of the index.  The searcher must be closed.

It does look like if you close the searcher and then close the request,
that might be enough to fully decrement all the reference counters
involved, but I do not know the code well enough to be sure of that.

Thanks,
Shawn

Reply via email to