Apache Solr open-source search software
useColdSearcher: LUCENE-77
Yonik Seeley462ca75cb9f1
diff --git a/CHANGES.txt b/CHANGES.txtindex 5a3222f0a4f..0d27129d763 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -92,6 +92,10 @@ New Features31. Support for "Date Math" relative "NOW" when specifying values of aDateField in a query -- or when adding a document.(hossman, SOLR-71)+32. useColdSearcher control in solrconfig.xml prevents the first searcher+ from being used before it's done warming. This can help prevent+ thrashing on startup when multiple requests hit a cold searcher.+ The default is "false", preventing use before warm. (yonik, SOLR-77)Changes in runtime behavior1. classes reorganized into different packages, package names changed to Apachediff --git a/src/java/org/apache/solr/core/SolrCore.java b/src/java/org/apache/solr/core/SolrCore.javaindex 8ba153f6c90..554b566eec5 100644--- a/src/java/org/apache/solr/core/SolrCore.java+++ b/src/java/org/apache/solr/core/SolrCore.java@@ -374,12 +374,16 @@ public final class SolrCore {try {+ boolean alreadyRegistered = false;synchronized (searcherLock) {if (_searcher == null) {- // if there isn't a current searcher then register this one- // before warming is complete instead of waiting.- registerSearcher(newSearchHolder);- decrementOnDeckCount[0]=false;+ // if there isn't a current searcher then we may+ // want to register this one before warming is complete instead of waiting.+ if (SolrConfig.config.getBool("query/useColdSearcher",false)) {+ registerSearcher(newSearchHolder);+ decrementOnDeckCount[0]=false;+ alreadyRegistered=true;+ }} else {// get a reference to the current searcher for purposes of autowarming.currSearcherHolder=_searcher;@@ -457,15 +461,14 @@ public final class SolrCore {// WARNING: this code assumes a single threaded executor (that all tasks// queued will finish first).final RefCounted<SolrIndexSearcher> currSearcherHolderF = currSearcherHolder;- Future finalFuture=null;- if (currSearcherHolder != null) {- finalFuture = searcherExecutor.submit(+ if (!alreadyRegistered) {+ future = searcherExecutor.submit(new Callable() {public Object call() throws Exception {try {// signal that we no longer need to decrement// the count *before* registering the searcher since- // registertSearcher will decrement even if it errors.+ // registerSearcher will decrement even if it errors.decrementOnDeckCount[0]=false;registerSearcher(newSearchHolder);} catch (Throwable e) {@@ -473,7 +476,7 @@ public final class SolrCore {} finally {// we are all done with the old searcher we used// for warming...- currSearcherHolderF.decref();+ if (currSearcherHolderF!=null) currSearcherHolderF.decref();}return null;}@@ -482,7 +485,7 @@ public final class SolrCore {}if (waitSearcher != null) {- waitSearcher[0] = finalFuture;+ waitSearcher[0] = future;}// Return the searcher as the warming tasks run in parallel