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 AlexeyK <le...@gmail.com> on 2012/12/20 07:20:43 UTC

SolrTestCaseJ4 and searcher initialization

Hi,
I've written a unit test for a custom search component, which naturally
extends the SolrTestCaseJ4.
beforeClass() has initCore(), assertU(adoc()) and assertU(commit()) inside.
The test creates a SolrQueryRequest via req() and runs h.query(request). In
other words, nothing special.
I see a rather strange SolrIndexSearcher initialization behavior:
1. 2 searchers are created one after another (OK).
2. When the second searcher finishes initialization, the first is closed
(NOT OK?).
3. Afterwards, the second searcher is also closed (REALLY NOT OK).
4. The test query seems to run against the already closed searcher.

I noticed this behavior because I have some custom cache in place, which is
populated during warmup. 2 instances of the cache are created and both are
later closed. After closing, the cache is being used in actual query, and
obviously it's already empty.
This seems like a race condition. Both searchers are being closed here:

if (!alreadyRegistered) {
        future = searcherExecutor.submit(
            new Callable() {
              public Object call() throws Exception {
                try {
                  // registerSearcher will decrement onDeckSearchers and
                  // do a notify, even if it fails.
                  registerSearcher(newSearchHolder);
                } catch (Throwable e) {
                  SolrException.log(log, e);
                } finally {
                  // we are all done with the old searcher we used
                  // for warming...
                  if (currSearcherHolderF!=null)
*currSearcherHolderF.decref();*
                }
                return null;
              }
            }
        );
      }



--
View this message in context: http://lucene.472066.n3.nabble.com/SolrTestCaseJ4-and-searcher-initialization-tp4028237.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: SolrTestCaseJ4 and searcher initialization

Posted by AlexeyK <le...@gmail.com>.
According to what I see, the basic LRUCache implementation has an empty
close(), that is why it still works for the already closed searcher.
According to the base interface, the close() is there for "freeing non
memory resources".

Can someone explain this counter intuitive behavior?
Why is it allowed to use the already closed searcher?(this is what happens
in my example).
Is this searcher ping-pong by purpose (see description above)?



--
View this message in context: http://lucene.472066.n3.nabble.com/SolrTestCaseJ4-and-searcher-initialization-tp4028237p4029011.html
Sent from the Solr - User mailing list archive at Nabble.com.