You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by yo...@apache.org on 2006/12/06 04:25:44 UTC

svn commit: r482875 - in /incubator/solr/trunk: CHANGES.txt src/java/org/apache/solr/core/SolrCore.java

Author: yonik
Date: Tue Dec  5 19:25:43 2006
New Revision: 482875

URL: http://svn.apache.org/viewvc?view=rev&rev=482875
Log:
useColdSearcher: LUCENE-77

Modified:
    incubator/solr/trunk/CHANGES.txt
    incubator/solr/trunk/src/java/org/apache/solr/core/SolrCore.java

Modified: incubator/solr/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/solr/trunk/CHANGES.txt?view=diff&rev=482875&r1=482874&r2=482875
==============================================================================
--- incubator/solr/trunk/CHANGES.txt (original)
+++ incubator/solr/trunk/CHANGES.txt Tue Dec  5 19:25:43 2006
@@ -92,6 +92,10 @@
 31. Support for "Date Math" relative "NOW" when specifying values of a
     DateField 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 behavior
  1. classes reorganized into different packages, package names changed to Apache

Modified: incubator/solr/trunk/src/java/org/apache/solr/core/SolrCore.java
URL: http://svn.apache.org/viewvc/incubator/solr/trunk/src/java/org/apache/solr/core/SolrCore.java?view=diff&rev=482875&r1=482874&r2=482875
==============================================================================
--- incubator/solr/trunk/src/java/org/apache/solr/core/SolrCore.java (original)
+++ incubator/solr/trunk/src/java/org/apache/solr/core/SolrCore.java Tue Dec  5 19:25:43 2006
@@ -374,12 +374,16 @@
 
     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 @@
       // 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 @@
                     } 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 @@
       }
 
       if (waitSearcher != null) {
-        waitSearcher[0] = finalFuture;
+        waitSearcher[0] = future;
       }
 
       // Return the searcher as the warming tasks run in parallel