Apache Lucene open-source search software
SOLR-9199: ZkController#publishAndWaitForDownStates logic is inefficient
Gregory Chanand55cc8f293ae
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex c8e7c1f6d59..ceb7a4a7054 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -52,6 +52,8 @@ Bug Fixes* SOLR-9191: OverseerTaskQueue.peekTopN() fatally flawed (Scott Blum, Noble Paul)+* SOLR-9199: ZkController#publishAndWaitForDownStates logic is inefficient (Hrishikesh Gadre)+================== 6.1.0 ==================Upgrading from Solr any prior releasediff --git a/solr/core/src/java/org/apache/solr/cloud/ZkController.java b/solr/core/src/java/org/apache/solr/cloud/ZkController.javaindex b36e7666513..1388ee53180 100644--- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java+++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java@@ -686,9 +686,9 @@ public final class ZkController {// now wait till the updates are in our statelong now = System.nanoTime();long timeout = now + TimeUnit.NANOSECONDS.convert(WAIT_DOWN_STATES_TIMEOUT_SECONDS, TimeUnit.SECONDS);- boolean foundStates = true;while (System.nanoTime() < timeout) {+ boolean foundStates = true;ClusterState clusterState = zkStateReader.getClusterState();Map<String, DocCollection> collections = clusterState.getCollectionsMap();for (Map.Entry<String, DocCollection> entry : collections.entrySet()) {@@ -704,16 +704,13 @@ public final class ZkController {}}+ Thread.sleep(1000);if (foundStates) {- Thread.sleep(1000);- break;+ return;}- Thread.sleep(1000);- }- if (!foundStates) {- log.warn("Timed out waiting to see all nodes published as DOWN in our cluster state.");}+ log.warn("Timed out waiting to see all nodes published as DOWN in our cluster state.");}/**