SOLR-15486: make SolrCoreState.pauseUpdatesAndAwaitInflightRequests logic not SolrCloud specific (#180)
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index d13ceed..b2b26a2 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -411,6 +411,9 @@
* SOLR-15573: bin/solr auth utility should provide role bindings for `security-read` and `config-edit` by default
to 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.java
index 9626799..bf80294 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 @@
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 @@
}
}
+ /**
+ * 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;
}