You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Priya Rodrigues <ro...@gmail.com> on 2014/11/19 14:37:07 UTC

IndexSearcher not being closed

Hi,

I am running into OOM errors on Solr 4.6. Our index size is quite small at
5000 documents and 75MB index size.

While debugging this OOM, I found that the IndexSearcher Refcount is not
coming down to 0 and hence the index searcher is not released on commits.

We are using custom request handlers - the handler spawns multiple internal
requests. All SolrQueryRequests created are closed at the end, refcounts
are incremented and then decremented,

The culprit seems to be TextResponseWriter, writeDocuments which is
incrementing the ref count twice. Snippets below.

context.searcher = req.getSearcher() -> RefCount incremented
    context.iterator = ids.iterator();
    if( transformer != null ) {
      transformer.setContext( context ) -> This calls setContext in the
class ValueSourceAugmenter, below
    }

public void setContext( TransformContext context ) {
    try {
      IndexReader reader = qparser.getReq().getSearcher().getIndexReader();
->Refcount incremented


Whereas the refcount is decremented just once
in SolrDispatchFilter, doFilter()

 finally {
        if( solrReq != null ) {
          log.debug("Closing out SolrRequest: {}", solrReq);
          solrReq.close(); -> RefCount decremented
        }
        if (core != null) {
          core.close();
        }
        SolrRequestInfo.clearRequestInfo();
      }

Is this a bug or am I missing something.

Thanks,
Priya

Re: IndexSearcher not being closed

Posted by Yonik Seeley <yo...@heliosearch.com>.
On Wed, Nov 19, 2014 at 8:37 AM, Priya Rodrigues <ro...@gmail.com> wrote:
> public void setContext( TransformContext context ) {
>     try {
>       IndexReader reader = qparser.getReq().getSearcher().getIndexReader();
> ->Refcount incremented

You can get a searcher from the request as many times as you like...
it's cached and the ref count is only incremented the first time (and
the corresponding decref is when the request object is closed).

-Yonik
http://heliosearch.org - native code faceting, facet functions,
sub-facets, off-heap data