Apache Solr open-source search software
SOLR-7840: ZkStateReader.updateClusterState fetches watched collections twice from ZK
Shalin Shekhar Mangarc8bdf9bf1982
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 0fbe7059236..d714568088b 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -272,7 +272,8 @@ OptimizationsFor Example: The facet request {type:terms, field:field1, facet:{x:"unique(field2)"}}saw a 7x improvement when field1 and 1M unique terms and field2 had 1000 unique terms.(yonik)-++* SOLR-7840: ZkStateReader.updateClusterState fetches watched collections twice from ZK. (shalin)Other Changes----------------------diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.javaindex a8a89c2f1b5..3fbcfaf4adc 100644--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java@@ -428,7 +428,7 @@ public class ZkStateReader implements Closeable {if (watchedCollections.contains(s)) {DocCollection live = getCollectionLive(this, s);if (live != null) {- watchedCollectionStates.put(s, live);+ updateWatchedCollection(live);// if it is a watched collection, add tooresult.put(s, new ClusterState.CollectionRef(live));}@@ -506,15 +506,6 @@ public class ZkStateReader implements Closeable {}this.clusterState = clusterState;}- synchronized (ZkStateReader.this) {- for (String watchedCollection : watchedCollections) {- DocCollection live = getCollectionLive(this, watchedCollection);- if (live != null) {- updateWatchedCollection(live);- }- }- }-} else {if (clusterStateUpdateScheduled) {log.debug("Cloud state update for ZooKeeper already scheduled");@@ -946,9 +937,7 @@ public class ZkStateReader implements Closeable {private void updateWatchedCollection(DocCollection newState) {watchedCollectionStates.put(newState.getName(), newState);- log.info("Updating data for {} to ver {} ", newState.getName(),- newState.getZNodeVersion());-+ log.info("Updating data for {} to ver {} ", newState.getName(), newState.getZNodeVersion());this.clusterState = clusterState.copyWith(newState.getName(), newState);}