Apache Solr open-source search software
SOLR-15136: Reduce excessive logging introduced with Per Replica States feature
Ishan Chattopadhyaya938039a6889f
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 2d96b841768..1d2794896fa 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -253,6 +253,8 @@ Bug Fixes* SOLR-15114: Fix bug that caused WAND optimization to be disabled in cases where the max score is requested (such asmulti-shard requests in SolrCloud) (Naoto Minami via Tomás Fernández Löbbe)+* SOLR-15136: Reduce excessive logging introduced with Per Replica States feature (Ishan Chattopadhyaya)+================== 8.8.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/PerReplicaStatesOps.java b/solr/solrj/src/java/org/apache/solr/common/cloud/PerReplicaStatesOps.javaindex a0d9a66aa23..3f2f5691c9d 100644--- a/solr/solrj/src/java/org/apache/solr/common/cloud/PerReplicaStatesOps.java+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/PerReplicaStatesOps.java@@ -60,7 +60,7 @@ public class PerReplicaStatesOps {List<Op> ops = new ArrayList<>(operations.size());for (PerReplicaStates.Operation op : operations) {- //the state of the replica is being updated+ // the state of the replica is being updatedString path = znode + "/" + op.state.asString;ops.add(op.typ == PerReplicaStates.Operation.Type.ADD ?Op.create(path, null, zkClient.getZkACLProvider().getACLsToAdd(path), CreateMode.PERSISTENT) :@@ -77,7 +77,8 @@ public class PerReplicaStatesOps {}- /**There is a possibility that a replica may have some leftover entries . delete them too+ /**+ * There is a possibility that a replica may have some leftover entries. Delete them too.*/private static List<PerReplicaStates.Operation> addDeleteStaleNodes(List<PerReplicaStates.Operation> ops, PerReplicaStates.State rs) {while (rs != null) {@@ -97,9 +98,9 @@ public class PerReplicaStatesOps {persist(operations, znode, zkClient);return;} catch (KeeperException.NodeExistsException | KeeperException.NoNodeException e) {- //state is stale+ // state is staleif(log.isInfoEnabled()) {- log.info("stale state for {} , attempt: {}. retrying...", znode, i);+ log.info("Stale state for {}, attempt: {}. retrying...", znode, i);}operations = refresh(PerReplicaStates.fetch(znode, zkClient, null));}@@ -111,7 +112,7 @@ public class PerReplicaStatesOps {}/**- * state of a replica is changed+ * Change the state of a replica** @param newState the new state*/@@ -168,21 +169,21 @@ public class PerReplicaStatesOps {ops.add(new PerReplicaStates.Operation(PerReplicaStates.Operation.Type.ADD, new PerReplicaStates.State(st.replica, Replica.State.ACTIVE, Boolean.TRUE, st.version + 1)));ops.add(new PerReplicaStates.Operation(PerReplicaStates.Operation.Type.DELETE, st));}- //else do not do anything , that node is the leader+ // else do not do anything, that node is the leader} else {- //there is no entry for the new leader.- //create one+ // there is no entry for the new leader.+ // create oneops.add(new PerReplicaStates.Operation(PerReplicaStates.Operation.Type.ADD, new PerReplicaStates.State(next, Replica.State.ACTIVE, Boolean.TRUE, 0)));}}- //now go through all other replicas and unset previous leader+ // now go through all other replicas and unset previous leaderfor (String r : allReplicas) {PerReplicaStates.State st = rs.get(r);if (st == null) continue;//unlikelyif (!Objects.equals(r, next)) {if (st.isLeader) {- //some other replica is the leader now. unset+ // some other replica is the leader now. unsetops.add(new PerReplicaStates.Operation(PerReplicaStates.Operation.Type.ADD, new PerReplicaStates.State(st.replica, st.state, Boolean.FALSE, st.version + 1)));ops.add(new PerReplicaStates.Operation(PerReplicaStates.Operation.Type.DELETE, st));}@@ -219,7 +220,7 @@ public class PerReplicaStatesOps {}/**- * mark a bunch of replicas as DOWN+ * Mark the given replicas as DOWN*/public static PerReplicaStatesOps downReplicas(List<String> replicas, PerReplicaStates rs) {return new PerReplicaStatesOps(prs -> {@@ -242,7 +243,7 @@ public class PerReplicaStatesOps {}/**- * Just creates and deletes a dummy entry so that the {@link Stat#getCversion()} of states.json+ * Just creates and deletes a dummy entry so that the {@link Stat#getCversion()} of state.json* is updated*/public static PerReplicaStatesOps touchChildren() {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 8aad1392b18..ccd93c6e165 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@@ -1463,7 +1463,7 @@ public class ZkStateReader implements SolrCloseable {ClusterState.initReplicaStateProvider(() -> {try {PerReplicaStates replicaStates = PerReplicaStates.fetch(collectionPath, zkClient, null);- log.info("per-replica-state ver: {} fetched for initializing {} ", replicaStates.cversion, collectionPath);+ log.debug("per-replica-state ver: {} fetched for initializing {} ", replicaStates.cversion, collectionPath);return replicaStates;} catch (Exception e) {//TODO