Apache Solr open-source search software
SOLR-2793: In rare cases (most likely during shutdown), a SolrIndexSearcher can be left open if the executor rejects a task.
Mark Robert Miller50b31b2a4ebe
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 3c53e22ec21..076ca87b884 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -368,6 +368,9 @@ Bug Fixes* SOLR-2780: Fixed issue where multi select facets didn't respect group.truncate parameter.(Martijn van Groningen, Ramzi Alqrainy)++* SOLR-2793: In rare cases (most likely during shutdown), a SolrIndexSearcher can be left+ open if the executor rejects a task. (Mark Miller)Other Changes----------------------diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.javaindex 368a22e8e4f..1bbfa7423a9 100644--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java@@ -1245,26 +1245,32 @@ public final class SolrCore implements SolrInfoMBean {// queued will finish first).final RefCounted<SolrIndexSearcher> currSearcherHolderF = currSearcherHolder;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- // registerSearcher will decrement even if it errors.- decrementOnDeckCount[0]=false;- registerSearcher(newSearchHolder);- } catch (Throwable e) {- SolrException.logOnce(log,null,e);- } finally {- // we are all done with the old searcher we used- // for warming...- if (currSearcherHolderF!=null) currSearcherHolderF.decref();+ try {+ 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+ // registerSearcher will decrement even if it errors.+ decrementOnDeckCount[0]=false;+ registerSearcher(newSearchHolder);+ } catch (Throwable e) {+ SolrException.logOnce(log,null,e);+ } finally {+ // we are all done with the old searcher we used+ // for warming...+ if (currSearcherHolderF!=null) currSearcherHolderF.decref();+ }+ return null;}- return null;}- }- );+ );+ } catch(Exception e) {+ // if submit fails, newSearchHolder does not get decref'd+ if (newSearchHolder != null) newSearchHolder.decref();+ throw e;+ }}if (waitSearcher != null) {