This is an automated email from the ASF dual-hosted git repository.
sarkaramrit1993 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/main by this push:
new 4890215acc8 SOLR-18602: Follow aliases in DELETEREPLICA by count
(#5259)
4890215acc8 is described below
commit 4890215acc8db102f293df50fd635c7270f0e59e
Author: Amrit Sarkar <[email protected]>
AuthorDate: Tue Nov 17 12:56:55 2026 -0800
SOLR-18602: Follow aliases in DELETEREPLICA by count (#5259)
---
.../solr-18602-deletereplica-count-alias.yml | 7 +++++++
.../cloud/api/collections/DeleteReplicaCmd.java | 8 +++++++-
.../org/apache/solr/cloud/DeleteReplicaTest.java | 22 ++++++++++++++++++++++
3 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/changelog/unreleased/solr-18602-deletereplica-count-alias.yml
b/changelog/unreleased/solr-18602-deletereplica-count-alias.yml
new file mode 100644
index 00000000000..38c40f3d11e
--- /dev/null
+++ b/changelog/unreleased/solr-18602-deletereplica-count-alias.yml
@@ -0,0 +1,7 @@
+title: "DELETEREPLICA with count now follows aliases when followAliases=true."
+type: fixed
+authors:
+ - name: Amrit Sarkar
+links:
+ - name: SOLR-18602
+ url: https://issues.apache.org/jira/browse/SOLR-18602
diff --git
a/solr/core/src/java/org/apache/solr/cloud/api/collections/DeleteReplicaCmd.java
b/solr/core/src/java/org/apache/solr/cloud/api/collections/DeleteReplicaCmd.java
index a2ad2cdd5b5..aad82ac03ce 100644
---
a/solr/core/src/java/org/apache/solr/cloud/api/collections/DeleteReplicaCmd.java
+++
b/solr/core/src/java/org/apache/solr/cloud/api/collections/DeleteReplicaCmd.java
@@ -119,7 +119,13 @@ public class DeleteReplicaCmd implements
CollectionApiCommand {
throws KeeperException, IOException, InterruptedException {
CollectionHandlingUtils.checkRequired(message, COLLECTION_PROP,
COUNT_PROP);
int count = Integer.parseInt(message.getStr(COUNT_PROP));
- String collectionName = message.getStr(COLLECTION_PROP);
+ String extCollectionName = message.getStr(COLLECTION_PROP);
+ String collectionName =
+ message.getBool(FOLLOW_ALIASES, false)
+ ? ccc.getSolrCloudManager()
+ .getClusterStateProvider()
+ .resolveSimpleAlias(extCollectionName)
+ : extCollectionName;
String shard = message.getStr(SHARD_ID_PROP);
DocCollection coll =
adminCmdContext.getClusterState().getCollection(collectionName);
Slice slice = null;
diff --git a/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java
b/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java
index 417285bd166..216b7b882ff 100644
--- a/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java
@@ -218,6 +218,28 @@ public class DeleteReplicaTest extends SolrCloudTestCase {
waitForState("Expected two shards with one replica each", collectionName,
clusterShape(2, 2));
}
+ @Test
+ public void deleteReplicaByCountFollowsAliases() throws Exception {
+ final String collectionName = "deleteByCountAlias";
+ final String aliasName = "deleteByCountAliasName";
+ CollectionAdminRequest.createCollection(collectionName, "conf", 2, 3)
+ .process(cluster.getSolrClient());
+ cluster.waitForActiveCollection(collectionName, 2, 6);
+ CollectionAdminRequest.createAlias(aliasName,
collectionName).process(cluster.getSolrClient());
+
+ CollectionAdminRequest.DeleteReplica forShard =
+ CollectionAdminRequest.deleteReplicasFromShard(aliasName, "shard1", 1);
+ forShard.setFollowAliases(true);
+ forShard.process(cluster.getSolrClient());
+ waitForState("Expected one replica deleted from shard1", collectionName,
clusterShape(2, 5));
+
+ CollectionAdminRequest.DeleteReplica forAllShards =
+ CollectionAdminRequest.deleteReplicasFromAllShards(aliasName, 1);
+ forAllShards.setFollowAliases(true);
+ forAllShards.process(cluster.getSolrClient());
+ waitForState("Expected one replica deleted per shard", collectionName,
clusterShape(2, 3));
+ }
+
@Test
public void deleteReplicaFromClusterState() throws Exception {
final String collectionName = "deleteFromClusterStateCollection";