diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 96a83b33eac..5d2b594f331 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -19,6 +19,8 @@ See the Quick Start guide at http://lucene.apache.org/solr/quickstart.html ================== 6.2.0 ================== (No Changes) +* SOLR-9199: ZkController#publishAndWaitForDownStates logic is inefficient (Hrishikesh Gadre) + ================== 6.1.0 ================== Upgrading from Solr any prior release diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkController.java b/solr/core/src/java/org/apache/solr/cloud/ZkController.java index 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 state long 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 collections = clusterState.getCollectionsMap(); for (Map.Entry entry : collections.entrySet()) { @@ -704,16 +704,13 @@ public final class ZkController { } } - if (foundStates) { - Thread.sleep(1000); - break; - } Thread.sleep(1000); - } - if (!foundStates) { - log.warn("Timed out waiting to see all nodes published as DOWN in our cluster state."); + if (foundStates) { + return; + } } + log.warn("Timed out waiting to see all nodes published as DOWN in our cluster state."); } /**