You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by no...@apache.org on 2023/03/13 04:50:24 UTC

[solr] branch jira/solr16653_4 updated: make force_set_state= true

This is an automated email from the ASF dual-hosted git repository.

noble pushed a commit to branch jira/solr16653_4
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/jira/solr16653_4 by this push:
     new 1aa0cb979ab make force_set_state= true
1aa0cb979ab is described below

commit 1aa0cb979ab5ae56313f6c2d2648b3612c4c2db4
Author: Noble Paul <no...@gmail.com>
AuthorDate: Mon Mar 13 15:50:14 2023 +1100

    make force_set_state= true
---
 .../org/apache/solr/cloud/overseer/ReplicaMutator.java     | 14 ++++++++------
 .../java/org/apache/solr/cloud/overseer/SliceMutator.java  |  2 ++
 .../solr/common/cloud/PerReplicaStatesIntegrationTest.java |  5 ++---
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/cloud/overseer/ReplicaMutator.java b/solr/core/src/java/org/apache/solr/cloud/overseer/ReplicaMutator.java
index 7674efa3cfa..1ca837bc8ff 100644
--- a/solr/core/src/java/org/apache/solr/cloud/overseer/ReplicaMutator.java
+++ b/solr/core/src/java/org/apache/solr/cloud/overseer/ReplicaMutator.java
@@ -440,12 +440,14 @@ public class ReplicaMutator {
     log.debug("Collection is now: {}", newCollection);
     if (collection.isPerReplicaState() && oldReplica != null) {
       if (!persistStateJson(replica, oldReplica, collection)) {
-        log.debug(
-            "state.json is not persisted slice/replica : {}/{} \n , old : {}, \n new {}",
-            replica.shard,
-            replica.name,
-            Utils.toJSONString(oldReplica.getProperties()),
-            Utils.toJSONString(replica.getProperties()));
+        if(log.isDebugEnabled()) {
+          log.debug(
+                  "state.json is not persisted slice/replica : {}/{} \n , old : {}, \n new {}",
+                  replica.shard,
+                  replica.name,
+                  Utils.toJSONString(oldReplica.getProperties()),
+                  Utils.toJSONString(replica.getProperties()));
+        }
         return ZkWriteCommand.NO_OP;
       }
     }
diff --git a/solr/core/src/java/org/apache/solr/cloud/overseer/SliceMutator.java b/solr/core/src/java/org/apache/solr/cloud/overseer/SliceMutator.java
index 01514af713b..56835a75273 100644
--- a/solr/core/src/java/org/apache/solr/cloud/overseer/SliceMutator.java
+++ b/solr/core/src/java/org/apache/solr/cloud/overseer/SliceMutator.java
@@ -22,6 +22,7 @@ import java.lang.invoke.MethodHandles;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Set;
 import org.apache.solr.client.solrj.cloud.DistribStateManager;
 import org.apache.solr.client.solrj.cloud.SolrCloudManager;
@@ -102,6 +103,7 @@ public class SliceMutator {
                 ZkStateReader.STATE_PROP, message.getStr(ZkStateReader.STATE_PROP),
                 ZkStateReader.NODE_NAME_PROP, nodeName,
                 ZkStateReader.BASE_URL_PROP, baseUrl,
+                ZkStateReader.FORCE_SET_STATE_PROP, "false",
                 ZkStateReader.REPLICA_TYPE, message.get(ZkStateReader.REPLICA_TYPE)),
             coll,
             slice);
diff --git a/solr/solrj/src/test/org/apache/solr/common/cloud/PerReplicaStatesIntegrationTest.java b/solr/solrj/src/test/org/apache/solr/common/cloud/PerReplicaStatesIntegrationTest.java
index 3e7e1ad9c21..18134645438 100644
--- a/solr/solrj/src/test/org/apache/solr/common/cloud/PerReplicaStatesIntegrationTest.java
+++ b/solr/solrj/src/test/org/apache/solr/common/cloud/PerReplicaStatesIntegrationTest.java
@@ -295,7 +295,7 @@ public class PerReplicaStatesIntegrationTest extends SolrCloudTestCase {
           .process(cluster.getSolrClient());
       stat = cluster.getZkClient().exists(DocCollection.getCollectionPath(PRS_COLL), null, true);
       // +1 after all replica are added with on state.json write to CreateCollectionCmd.setData()
-      assertEquals(11, stat.getVersion());
+      assertEquals(1, stat.getVersion());
       // For each replica:
       // +1 for ZkController#preRegister, in ZkController#publish, direct write PRS to down
       // +2 for runLeaderProcess, flip the replica to leader
@@ -333,14 +333,13 @@ public class PerReplicaStatesIntegrationTest extends SolrCloudTestCase {
       // +1 for ZkController#unregister, which delete the PRS entry from data node
       // overseer, current code would still do a "TOUCH" on the PRS entry
       assertEquals(56, stat.getCversion());
-
       for (JettySolrRunner j : cluster.getJettySolrRunners()) {
         j.stop();
         j.start(true);
         stat = cluster.getZkClient().exists(DocCollection.getCollectionPath(PRS_COLL), null, true);
         // ensure restart does not update the state.json, after addReplica/deleteReplica, 2 more
         // updates hence at version 3 on state.json version
-        assertEquals(14, stat.getVersion());
+        assertEquals(3, stat.getVersion());
       }
     } finally {
       cluster.shutdown();