Apache Solr open-source search software
SOLR-15486: make SolrCoreState.pauseUpdatesAndAwaitInflightRequests logic not SolrCloud specific (#180)
Christine Poerschkebab9d2878c36
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex d13ceed6df7..b2b26a2393d 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -411,6 +411,9 @@ Other Changes* SOLR-15573: bin/solr auth utility should provide role bindings for `security-read` and `config-edit` by defaultto protect the security and schema designer screens in the Admin UI (Timothy Potter)+* SOLR-15486: During node shutdown pausing of updates and waiting for in-flight update requests to finish+ before closing cores is no longer SolrCloud specific. (Christine Poerschke, David Smiley)+================== 8.9.0 ==================Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.javaindex 9626799863e..bf802942c29 100644--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java@@ -1033,26 +1033,9 @@ public class CoreContainer {if (isZooKeeperAware()) {cancelCoreRecoveries();zkSys.zkController.preClose();- /*- * Pause updates for all cores on this node and wait for all in-flight update requests to finish.- * Here, we (slightly) delay leader election so that in-flight update requests succeed and we can preserve consistency.- *- * Jetty already allows a grace period for in-flight requests to complete and our solr cores, searchers etc- * are reference counted to allow for graceful shutdown. So we don't worry about any other kind of requests.- *- * We do not need to unpause ever because the node is being shut down.- */- getCores().parallelStream().forEach(solrCore -> {- SolrCoreState solrCoreState = solrCore.getSolrCoreState();- try {- solrCoreState.pauseUpdatesAndAwaitInflightRequests();- } catch (TimeoutException e) {- log.warn("Timed out waiting for in-flight update requests to complete for core: {}", solrCore.getName());- } catch (InterruptedException e) {- log.warn("Interrupted while waiting for in-flight update requests to complete for core: {}", solrCore.getName());- Thread.currentThread().interrupt();- }- });+ }+ pauseUpdatesAndAwaitInflightRequests();+ if (isZooKeeperAware()) {zkSys.zkController.tryCancelAllElections();}@@ -1206,6 +1189,29 @@ public class CoreContainer {}}+ /**+ * Pause updates for all cores on this node and wait for all in-flight update requests to finish.+ * Here, we (slightly) delay leader election so that in-flight update requests succeed and we can preserve consistency.+ *+ * Jetty already allows a grace period for in-flight requests to complete and our solr cores, searchers etc+ * are reference counted to allow for graceful shutdown. So we don't worry about any other kind of requests.+ *+ * We do not need to unpause ever because the node is being shut down.+ */+ private void pauseUpdatesAndAwaitInflightRequests() {+ getCores().parallelStream().forEach(solrCore -> {+ SolrCoreState solrCoreState = solrCore.getSolrCoreState();+ try {+ solrCoreState.pauseUpdatesAndAwaitInflightRequests();+ } catch (TimeoutException e) {+ log.warn("Timed out waiting for in-flight update requests to complete for core: {}", solrCore.getName());+ } catch (InterruptedException e) {+ log.warn("Interrupted while waiting for in-flight update requests to complete for core: {}", solrCore.getName());+ Thread.currentThread().interrupt();+ }+ });+ }+public CoresLocator getCoresLocator() {return coresLocator;}