You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by no...@apache.org on 2021/10/28 05:05:44 UTC

[lucene-solr] branch branch_8x updated: SOLR-15722: Delete Replica does not delete the Per replica state (#2596)

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

noble pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/branch_8x by this push:
     new 7765b67  SOLR-15722: Delete Replica does not delete the Per replica state (#2596)
7765b67 is described below

commit 7765b6786d0cfdf8954cd1d73cad45f0b4f7299e
Author: Noble Paul <no...@users.noreply.github.com>
AuthorDate: Thu Oct 28 16:05:31 2021 +1100

    SOLR-15722: Delete Replica does not delete the Per replica state (#2596)
---
 solr/CHANGES.txt                                                     | 1 +
 solr/core/src/java/org/apache/solr/cloud/overseer/SliceMutator.java  | 3 ++-
 .../test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java  | 5 +++++
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index bf037cf..9b02acc 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -36,6 +36,7 @@ Bug Fixes
 
 * SOLR-15628: The SolrException.log() helper method has been fixed to correctly passes the Throwable to the Logger w/o stringification (hossman)
 
+* SOLR-15722: Delete Replica does not delete the Per replica state (noble)
 Build
 ---------------------
 
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 d0f08cc..c57cdbd 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
@@ -131,7 +131,8 @@ public class SliceMutator {
 
 
     if (coll.isPerReplicaState()) {
-      return new ZkWriteCommand(collection, coll.copyWithSlices(newSlices), PerReplicaStatesOps.deleteReplica(cnn, coll.getPerReplicaStates()) , true);
+      PerReplicaStatesOps replicaOps = PerReplicaStatesOps.deleteReplica(cnn, PerReplicaStates.fetch(coll.getZNode(), zkClient, coll.getPerReplicaStates()) );
+      return new ZkWriteCommand(collection, coll.copyWithSlices(newSlices), replicaOps, true);
     } else {
       return new ZkWriteCommand(collection, coll.copyWithSlices(newSlices));
     }
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java
index 6f94315..853b3e3 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java
@@ -1121,6 +1121,11 @@ public class CloudSolrClientTest extends SolrCloudTestCase {
     prs = PerReplicaStates.fetch(ZkStateReader.getCollectionPath(testCollection), cluster.getZkClient(), null);
     assertEquals(5, prs.states.size());
 
+    c = cluster.getSolrClient().getZkStateReader().getCollection(testCollection);
+    Replica toDelete = c.getReplica((shard, replica) -> "shard1".equals(shard) && !replica.isLeader());
+    CollectionAdminRequest.deleteReplica(testCollection, "shard1", toDelete.getName()).process(cluster.getSolrClient());
+    cluster.waitForActiveCollection(testCollection, 2, 4);
+
     testCollection = "perReplicaState_testv2";
     new V2Request.Builder("/collections")
         .withMethod(POST)