SOLR-2197: wait for search executor to close before closing main server

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1024476 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2010-10-20 01:21:28 +00:00
parent a817987d92
commit a5595ede47
1 changed files with 39 additions and 7 deletions

View File

@ -685,6 +685,19 @@ public final class SolrCore implements SolrInfoMBean {
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 SolrInfoMBean {
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 SolrInfoMBean {
_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);