You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by yo...@apache.org on 2010/10/20 03:21:28 UTC

svn commit: r1024476 - /lucene/dev/trunk/solr/src/java/org/apache/solr/core/SolrCore.java

Author: yonik
Date: Wed Oct 20 01:21:28 2010
New Revision: 1024476

URL: http://svn.apache.org/viewvc?rev=1024476&view=rev
Log:
SOLR-2197: wait for search executor to close before closing main server

Modified:
    lucene/dev/trunk/solr/src/java/org/apache/solr/core/SolrCore.java

Modified: lucene/dev/trunk/solr/src/java/org/apache/solr/core/SolrCore.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/java/org/apache/solr/core/SolrCore.java?rev=1024476&r1=1024475&r2=1024476&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/java/org/apache/solr/core/SolrCore.java (original)
+++ lucene/dev/trunk/solr/src/java/org/apache/solr/core/SolrCore.java Wed Oct 20 01:21:28 2010
@@ -685,6 +685,19 @@ public final class SolrCore implements S
       return;
     }
     log.info(logid+" CLOSING SolrCore " + this);
+
+
+    if( closeHooks != null ) {
+       for( CloseHook hook : closeHooks ) {
+         try {
+           hook.close( this );
+         } catch (Throwable e) {
+           SolrException.log(log, e);           
+         }
+      }
+    }
+
+
     try {
       infoRegistry.clear();
     } catch (Exception e) {
@@ -696,20 +709,27 @@ public final class SolrCore implements S
       SolrException.log(log,e);
     }
     try {
-      closeSearcher();
+      searcherExecutor.shutdown();
+      if (!searcherExecutor.awaitTermination(60, TimeUnit.SECONDS)) {
+        log.error("Timeout waiting for searchExecutor to terminate");
+      }
     } catch (Exception e) {
       SolrException.log(log,e);
     }
     try {
-      searcherExecutor.shutdown();
+      // Since we waited for the searcherExecutor to shut down,
+      // there should be no more searchers warming in the background
+      // that we need to take care of.
+      //
+      // For the case that a searcher was registered *before* warming
+      // then the searchExecutor will throw an exception when getSearcher()
+      // tries to use it, and the exception handling code should close it.
+      closeSearcher();
     } catch (Exception e) {
       SolrException.log(log,e);
     }
-    if( closeHooks != null ) {
-       for( CloseHook hook : closeHooks ) {
-         hook.close( this );
-      }
-    }
+
+
   }
 
   /** Current core usage count. */
@@ -1275,6 +1295,18 @@ public final class SolrCore implements S
         _searcher = newSearcherHolder;
         SolrIndexSearcher newSearcher = newSearcherHolder.get();
 
+        /***
+        // a searcher may have been warming asynchronously while the core was being closed.
+        // if this happens, just close the searcher.
+        if (isClosed()) {
+          // NOTE: this should not happen now - see close() for details.
+          // *BUT* if we left it enabled, this could still happen before
+          // close() stopped the executor - so disable this test for now.
+          log.error("Ignoring searcher register on closed core:" + newSearcher);
+          _searcher.decref();
+        }
+        ***/
+
         newSearcher.register(); // register subitems (caches)
         log.info(logid+"Registered new searcher " + newSearcher);