Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-8693: Improve ZkStateReader logging.

markrmiller3124a4debdea
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 42c57c1fa56..a57f8e53776 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -286,6 +286,8 @@ Other Changes
* SOLR-8677: Prevent shards containing invalid characters from being created. Checks added server-side
and in SolrJ. (Shai Erera, Jason Gerlowski, Anshum Gupta)
+* SOLR-8693: Improve ZkStateReader logging. (Scott Blum via Mark Miller)
+
======================= 5.5.0 =======================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release
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.java
index 910b47e0407..a904f3ea4b0 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
@@ -29,6 +29,7 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
@@ -420,11 +421,21 @@ public class ZkStateReader implements Closeable {
this.clusterState = new ClusterState(liveNodes, result, legacyClusterStateVersion);
LOG.debug("clusterStateSet: version [{}] legacy [{}] interesting [{}] watched [{}] lazy [{}] total [{}]",
clusterState.getZkClusterStateVersion(),
- legacyCollectionStates.keySet(),
- interestingCollections,
- watchedCollectionStates.keySet(),
- lazyCollectionStates.keySet(),
- clusterState.getCollections());
+ legacyCollectionStates.keySet().size(),
+ interestingCollections.size(),
+ watchedCollectionStates.keySet().size(),
+ lazyCollectionStates.keySet().size(),
+ clusterState.getCollectionStates().size());
+
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("clusterStateSet: version [{}] legacy [{}] interesting [{}] watched [{}] lazy [{}] total [{}]",
+ clusterState.getZkClusterStateVersion(),
+ legacyCollectionStates.keySet(),
+ interestingCollections,
+ watchedCollectionStates.keySet(),
+ lazyCollectionStates.keySet(),
+ clusterState.getCollectionStates());
+ }
}
/**
@@ -533,17 +544,22 @@ public class ZkStateReader implements Closeable {
Set<String> newLiveNodes;
try {
List<String> nodeList = zkClient.getChildren(LIVE_NODES_ZKNODE, watcher, true);
- LOG.debug("Updating live nodes from ZooKeeper... [{}]", nodeList.size());
newLiveNodes = new HashSet<>(nodeList);
} catch (KeeperException.NoNodeException e) {
newLiveNodes = emptySet();
}
+ Set<String> oldLiveNodes;
synchronized (getUpdateLock()) {
+ oldLiveNodes = this.liveNodes;
this.liveNodes = newLiveNodes;
if (clusterState != null) {
clusterState.setLiveNodes(newLiveNodes);
}
}
+ LOG.info("Updated live nodes from ZooKeeper... ({}) -> ({})", oldLiveNodes.size(), newLiveNodes.size());
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Updated live nodes from ZooKeeper... {} -> {}", new TreeSet<>(oldLiveNodes), new TreeSet<>(newLiveNodes));
+ }
}
/**