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/06 10:36:05 UTC

[solr] branch jira/solr16653_3 updated: fixed the bug

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

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


The following commit(s) were added to refs/heads/jira/solr16653_3 by this push:
     new 21b1688588d fixed the bug
21b1688588d is described below

commit 21b1688588d2ed29df097e3d4d808f89ad975b44
Author: Noble Paul <no...@gmail.com>
AuthorDate: Mon Mar 6 21:35:54 2023 +1100

    fixed the bug
---
 .../apache/solr/cloud/overseer/ReplicaMutator.java   | 20 ++++++++++++++++++++
 .../solr/cloud/SplitShardWithNodeRoleTest.java       |  6 +++---
 2 files changed, 23 insertions(+), 3 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 b030346777f..58cf81502ca 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
@@ -29,6 +29,7 @@ import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.NoSuchElementException;
+import java.util.Objects;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
 import org.apache.commons.lang3.StringUtils;
@@ -437,9 +438,28 @@ public class ReplicaMutator {
 
     DocCollection newCollection = CollectionMutator.updateSlice(collectionName, collection, slice);
     log.debug("Collection is now: {}", newCollection);
+    if (collection.isPerReplicaState() && oldReplica != null) {
+      if (!writeStateJson(replica, oldReplica, newCollection)) {
+        return ZkWriteCommand.NO_OP;
+      }
+    }
     return new ZkWriteCommand(collectionName, newCollection);
   }
 
+  private boolean writeStateJson(Replica newReplica, Replica oldReplica, DocCollection newColl) {
+    if (!Objects.equals(newReplica.getBaseUrl(), oldReplica.getBaseUrl())) return true;
+    if (!Objects.equals(newReplica.getCoreName(), oldReplica.getCoreName())) return true;
+    if (!Objects.equals(newReplica.getNodeName(), oldReplica.getNodeName())) return true;
+    if (!Objects.equals(
+        newReplica.getProperties().get(ZkStateReader.FORCE_SET_STATE_PROP),
+        oldReplica.getProperties().get(ZkStateReader.FORCE_SET_STATE_PROP))) return true;
+    Slice.State sliceState = newColl.getSlice(newReplica.getShard()).getState();
+    if (sliceState == Slice.State.CONSTRUCTION || sliceState == Slice.State.RECOVERY) return true;
+    if (oldReplica.getState() == Replica.State.RECOVERING) return true;
+    if (newReplica.getState() == Replica.State.RECOVERING) return true;
+    return false;
+  }
+
   private DocCollection checkAndCompleteShardSplit(
       ClusterState prevState,
       DocCollection collection,
diff --git a/solr/core/src/test/org/apache/solr/cloud/SplitShardWithNodeRoleTest.java b/solr/core/src/test/org/apache/solr/cloud/SplitShardWithNodeRoleTest.java
index 7e7074a1df6..78bbbc8e015 100644
--- a/solr/core/src/test/org/apache/solr/cloud/SplitShardWithNodeRoleTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/SplitShardWithNodeRoleTest.java
@@ -57,12 +57,12 @@ public class SplitShardWithNodeRoleTest extends SolrCloudTestCase {
 
   @Test
   public void testSolrClusterWithNodeRoleWithSingleReplica() throws Exception {
-    doSplit("coll_NO_HA", 1, 1, 0);
+    doSplit("coll_ONLY_NRT", 1, 1, 0);
   }
 
   @Test
-  public void testSolrClusterWithNodeRoleWithHA() throws Exception {
-    doSplit("coll_HA", 1, 1, 1);
+  public void testSolrClusterWithNodeRoleWithPull() throws Exception {
+    doSplit("coll_NRT_PULL", 1, 1, 1);
   }
 
   public void doSplit(String collName, int shard, int nrtReplica, int pullReplica)