Hi,

In our Solr deployment we have a cluster of replicated Solr cores, with the
small change that we have dynamic master look-up using ZooKeeper. The
problem I am trying to solve is to make sure that when a new Solr core joins
the cluster it isn't made available to any search services until it has been
filled with data.

I am not familiar with Solr internals, so the approach I wanted to take was
to basically check the numDocs property of the index during start-up and set
a READABLE state in the ZooKeeper node if it's greater than 0. I also
planned to create a commit hook for replication and updating which
controlled the READABLE property based on numDocs also.

This just leaves the problem of finding out the number of documents during
start-up. I planned to have something like:

int numDocs = 0;
RefCounted<SolrIndexSearcher> searcher = core.getSearcher();
try {
   numDocs = searcher.get().getIndexReader().numDocs();
} finally {
    searcher.decref();
}

but getSearcher's documentation specifically says don't use it from the
inform method. I missed this at first and of course I got a deadlock
(although only when I had more than one core on the same Solr instance).

Is there a simpler way to do what I want? Or will I just need to have a
thread which waits until the Searcher is available before setting the
state?

Thanks,
David

Reply via email to