You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2020/01/14 09:51:22 UTC
[GitHub] [lucene-solr] sarkaramrit2 opened a new pull request #1167:
SOLR-13845: DELETEREPLICA API by count and type
sarkaramrit2 opened a new pull request #1167: SOLR-13845: DELETEREPLICA API by count and type
URL: https://github.com/apache/lucene-solr/pull/1167
<!--
_(If you are a project committer then you may remove some/all of the following template.)_
Before creating a pull request, please file an issue in the ASF Jira system for Lucene or Solr:
* https://issues.apache.org/jira/projects/LUCENE
* https://issues.apache.org/jira/projects/SOLR
You will need to create an account in Jira in order to create an issue.
The title of the PR should reference the Jira issue number in the form:
* LUCENE-####: <short description of problem or changes>
* SOLR-####: <short description of problem or changes>
LUCENE and SOLR must be fully capitalized. A short description helps people scanning pull requests for items they can work on.
Properly referencing the issue in the title ensures that Jira is correctly updated with code review comments and commits. -->
# Description
Please provide a short description of the changes you're making with this pull request.
# Solution
Please provide a short description of the approach taken to implement your solution.
# Tests
Please describe the tests you've developed or run to confirm this patch implements the feature or solves the problem.
# Checklist
Please review the following and check all that apply:
- [ ] I have reviewed the guidelines for [How to Contribute](https://wiki.apache.org/solr/HowToContribute) and my code conforms to the standards described there to the best of my ability.
- [ ] I have created a Jira issue and added the issue ID to my pull request title.
- [ ] I have given Solr maintainers [access](https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork) to contribute to my PR branch. (optional but recommended)
- [ ] I have developed this patch against the `master` branch.
- [ ] I have run `ant precommit` and the appropriate test suite.
- [ ] I have added tests for my changes.
- [ ] I have added documentation for the [Ref Guide](https://github.com/apache/lucene-solr/tree/master/solr/solr-ref-guide) (for Solr changes only).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] CaoManhDat commented on a change in pull request
#1167: SOLR-13845: DELETEREPLICA API by count and type
Posted by GitBox <gi...@apache.org>.
CaoManhDat commented on a change in pull request #1167: SOLR-13845: DELETEREPLICA API by count and type
URL: https://github.com/apache/lucene-solr/pull/1167#discussion_r380999141
##########
File path: solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
##########
@@ -2298,6 +2299,20 @@ public static DeleteReplica deleteReplicasFromAllShards(String collection, int c
return new DeleteReplica(collection, count);
}
+ public static DeleteReplica deleteReplica(String collection, String shard, int count, Replica.Type type) {
+ return new DeleteReplica(collection, checkNotNull(CoreAdminParams.SHARD, shard), count, type);
+ }
+ /**
+ * Returns a SolrRequest to remove a number of replicas from a specific shard of specific type
+ */
+ public static DeleteReplica deleteReplicasFromShard(String collection, String shard, int count, Replica.Type type) {
+ return new DeleteReplica(collection, checkNotNull(CoreAdminParams.SHARD, shard), count, type);
+ }
+ public static DeleteReplica deleteReplicasFromAllShards(String collection, int count, Replica.Type type) {
Review comment:
and here
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] CaoManhDat commented on a change in pull request
#1167: SOLR-13845: DELETEREPLICA API by count and type
Posted by GitBox <gi...@apache.org>.
CaoManhDat commented on a change in pull request #1167: SOLR-13845: DELETEREPLICA API by count and type
URL: https://github.com/apache/lucene-solr/pull/1167#discussion_r381002805
##########
File path: solr/solr-ref-guide/src/replica-management.adoc
##########
@@ -212,6 +212,11 @@ The number of replicas to remove. If the requested number exceeds the number of
+
If `replica` is used instead, this parameter is not required. Otherwise, this parameter must be supplied.
+`type`::
+
+The type of replicas to remove. This parameter compliments `count` parameter. If the requested number exceeds the number of replicas of a certain type specified, no replicas will be deleted.If we tend to remove all TLOG and NRT type replicas (replica types eligible to become leader of shard), the request will not be processed.
+If `replica` is used instead, this parameter is not required. Otherwise, this parameter can be supplied with `count` parameter.
Review comment:
I don't think we need to mention this point. Plus this point quite confuse to me, normally it will be `... this parameter is not required. Otherwise, it must be be specified`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] CaoManhDat commented on a change in pull request
#1167: SOLR-13845: DELETEREPLICA API by count and type
Posted by GitBox <gi...@apache.org>.
CaoManhDat commented on a change in pull request #1167: SOLR-13845: DELETEREPLICA API by count and type
URL: https://github.com/apache/lucene-solr/pull/1167#discussion_r381003552
##########
File path: solr/core/src/java/org/apache/solr/cloud/api/collections/DeleteReplicaCmd.java
##########
@@ -187,44 +201,66 @@ void deleteReplicaBasedOnCount(ClusterState clusterState,
* Validate if there is less replicas than requested to remove. Also error out if there is
* only one replica available
*/
- private void validateReplicaAvailability(Slice slice, String shard, String collectionName, int count) {
+ private void validateReplicaAvailability(Slice slice, String shard, String collectionName, int count, Replica.Type type) {
//If there is a specific shard passed, validate if there any or just 1 replica left
if (slice != null) {
Collection<Replica> allReplicasForShard = slice.getReplicas();
if (allReplicasForShard == null) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "No replicas found in shard/collection: " +
- shard + "/" + collectionName);
+ shard + "/" + collectionName);
}
+ if (type == null) {
+ if (allReplicasForShard.size() == 1) {
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "There is only one replica available in shard/collection: " +
+ shard + "/" + collectionName + ". Cannot delete that.");
+ }
- if (allReplicasForShard.size() == 1) {
- throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "There is only one replica available in shard/collection: " +
- shard + "/" + collectionName + ". Cannot delete that.");
- }
-
- if (allReplicasForShard.size() <= count) {
- throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "There are lesser num replicas requested to be deleted than are available in shard/collection : " +
- shard + "/" + collectionName + " Requested: " + count + " Available: " + allReplicasForShard.size() + ".");
+ if (allReplicasForShard.size() <= count) {
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "There are lesser num replicas requested to be deleted than are available in shard/collection : " +
+ shard + "/" + collectionName + " Requested: " + count + " Available: " + allReplicasForShard.size() + ".");
+ }
+ } else {
+ int nrtReplicas = slice.getReplicas(EnumSet.of(Replica.Type.NRT)).size();
+ int pullReplicas = slice.getReplicas(EnumSet.of(Replica.Type.PULL)).size();
+ int tlogReplicas = slice.getReplicas(EnumSet.of(Replica.Type.TLOG)).size();
+
Review comment:
we do not always need to compute these 3 variables all the time, so it can be computed later after we look into type.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] CaoManhDat commented on a change in pull request
#1167: SOLR-13845: DELETEREPLICA API by count and type
Posted by GitBox <gi...@apache.org>.
CaoManhDat commented on a change in pull request #1167: SOLR-13845: DELETEREPLICA API by count and type
URL: https://github.com/apache/lucene-solr/pull/1167#discussion_r381000486
##########
File path: solr/solr-ref-guide/src/replica-management.adoc
##########
@@ -212,6 +212,11 @@ The number of replicas to remove. If the requested number exceeds the number of
+
If `replica` is used instead, this parameter is not required. Otherwise, this parameter must be supplied.
+`type`::
+
Review comment:
may be remove this line
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] CaoManhDat commented on a change in pull request
#1167: SOLR-13845: DELETEREPLICA API by count and type
Posted by GitBox <gi...@apache.org>.
CaoManhDat commented on a change in pull request #1167: SOLR-13845: DELETEREPLICA API by count and type
URL: https://github.com/apache/lucene-solr/pull/1167#discussion_r381007584
##########
File path: solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java
##########
@@ -170,6 +170,58 @@ public void deleteReplicaAndVerifyDirectoryCleanup() throws Exception {
assertFalse("DataDirectory still exists", Files.exists(Paths.get(coreStatus.getDataDirectory())));
}
+ @Test
+ public void deleteReplicaByCountWithType() throws Exception {
+
+ final String collectionName = "deleteByCountWithType";
+
+ Create req = CollectionAdminRequest.createCollection(collectionName, "conf", 1, 2, 0, 2);
+ req.setMaxShardsPerNode(2);
+ req.process(cluster.getSolrClient());
+ waitForState("Expected a single shard with six replicas", collectionName, clusterShape(1, 4));
+
+ CollectionAdminRequest.deleteReplicasFromShard(collectionName, "shard1", 1, Replica.Type.NRT).process(cluster.getSolrClient());
+ waitForState("Expected a single shard with a single NRT replica", collectionName, clusterShape(1, 1, Replica.Type.NRT));
+ waitForState("Expected a single shard with two PULL replicas", collectionName, clusterShape(1, 2, Replica.Type.PULL));
+
+ CollectionAdminRequest.deleteReplicasFromShard(collectionName, "shard1", 2, Replica.Type.PULL).process(cluster.getSolrClient());
+ waitForState("Expected a single shard with a single PULL replica", collectionName, clusterShape(1, 0, Replica.Type.PULL));
+
+ SolrException e = expectThrows(SolrException.class,
+ "Can't delete the last replica by count",
+ () -> CollectionAdminRequest.deleteReplicasFromShard(collectionName, "shard1", 1, Replica.Type.NRT).process(cluster.getSolrClient())
+ );
+ assertEquals(SolrException.ErrorCode.BAD_REQUEST.code, e.code());
+ assertTrue(e.getMessage().contains("There are lesser num replicas or qualified leaders requested to be deleted than are available in shard/collection"));
+ DocCollection docCollection = getCollectionState(collectionName);
+ // We know that since leaders are preserved, PULL replicas should not be left alone in the shard
+ assertEquals(0, docCollection.getSlice("shard1").getReplicas(EnumSet.of(Replica.Type.PULL)).size());
+ }
+
+ @Test
+ // commented out on: 17-Feb-2019 @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // annotated on: 24-Dec-2018
+ public void deleteReplicaByCountForAllShardsWithType() throws Exception {
+
+ final String collectionName = "deleteByCountNewWithType";
+ Create req = CollectionAdminRequest.createCollection(collectionName, "conf", 2, 2, 2, 2);
+ req.setMaxShardsPerNode(3);
+ req.process(cluster.getSolrClient());
+
+ cluster.waitForActiveCollection(collectionName, 2, 12);
+
+ waitForState("Expected two shards with six replicas each", collectionName, clusterShape(2, 12));
+
+ CollectionAdminRequest.deleteReplicasFromAllShards(collectionName, 1, Replica.Type.NRT).process(cluster.getSolrClient());
+ waitForState("Expected two shards with one replica each", collectionName, clusterShape(2, 2, Replica.Type.NRT));
+
+ CollectionAdminRequest.deleteReplicasFromAllShards(collectionName, 1, Replica.Type.TLOG).process(cluster.getSolrClient());
+ waitForState("Expected two shards with one replica each", collectionName, clusterShape(2, 2, Replica.Type.TLOG));
+
+ CollectionAdminRequest.deleteReplicasFromAllShards(collectionName, 1, Replica.Type.PULL).process(cluster.getSolrClient());
+ waitForState("Expected two shards with one replica each", collectionName, clusterShape(2, 2, Replica.Type.PULL));
Review comment:
I think three assert messages above is not correct.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] sarkaramrit2 commented on a change in pull request
#1167: SOLR-13845: DELETEREPLICA API by count and type
Posted by GitBox <gi...@apache.org>.
sarkaramrit2 commented on a change in pull request #1167: SOLR-13845: DELETEREPLICA API by count and type
URL: https://github.com/apache/lucene-solr/pull/1167#discussion_r378082629
##########
File path: solr/core/src/java/org/apache/solr/cloud/api/collections/DeleteReplicaCmd.java
##########
@@ -187,44 +201,66 @@ void deleteReplicaBasedOnCount(ClusterState clusterState,
* Validate if there is less replicas than requested to remove. Also error out if there is
* only one replica available
*/
- private void validateReplicaAvailability(Slice slice, String shard, String collectionName, int count) {
+ private void validateReplicaAvailability(Slice slice, String shard, String collectionName, int count, Replica.Type type) {
//If there is a specific shard passed, validate if there any or just 1 replica left
if (slice != null) {
Collection<Replica> allReplicasForShard = slice.getReplicas();
if (allReplicasForShard == null) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "No replicas found in shard/collection: " +
- shard + "/" + collectionName);
+ shard + "/" + collectionName);
}
+ if (type == null) {
+ if (allReplicasForShard.size() == 1) {
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "There is only one replica available in shard/collection: " +
+ shard + "/" + collectionName + ". Cannot delete that.");
+ }
- if (allReplicasForShard.size() == 1) {
- throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "There is only one replica available in shard/collection: " +
- shard + "/" + collectionName + ". Cannot delete that.");
- }
-
- if (allReplicasForShard.size() <= count) {
- throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "There are lesser num replicas requested to be deleted than are available in shard/collection : " +
- shard + "/" + collectionName + " Requested: " + count + " Available: " + allReplicasForShard.size() + ".");
+ if (allReplicasForShard.size() <= count) {
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "There are lesser num replicas requested to be deleted than are available in shard/collection : " +
+ shard + "/" + collectionName + " Requested: " + count + " Available: " + allReplicasForShard.size() + ".");
+ }
+ } else {
+ int nrtReplicas = slice.getReplicas(EnumSet.of(Replica.Type.NRT)).size();
+ int pullReplicas = slice.getReplicas(EnumSet.of(Replica.Type.PULL)).size();
+ int tlogReplicas = slice.getReplicas(EnumSet.of(Replica.Type.TLOG)).size();
+
+ if (type.equals(Replica.Type.PULL)) {
+ if (pullReplicas < count) {
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "There are lesser num replicas requested to be deleted than are available in type/shard/collection : " +
+ type + "/" + shard + "/" + collectionName + " Requested: " + count + " Available: " + pullReplicas + ".");
+ }
+ } else if (type.equals(Replica.Type.NRT)) {
+ if (nrtReplicas <= count && tlogReplicas < 1) {
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "There are lesser num replicas or qualified leaders requested to be deleted than are available in shard/collection : " +
+ shard + "/" + collectionName + " Requested: " + count + " Available: " + nrtReplicas + ".");
+ }
+ } else if (type.equals(Replica.Type.TLOG)) {
Review comment:
Thanks, @anshumg for the review. The checks are in place to avoid such a situation where we delete the only qualified leaders.
Are you suggesting parallel delete-by-count-and-type requests can create such a situation where we delete all qualified leaders? The replica count is read from Clusterstate, where we have the appropriate read-write lock, so the logic should be good. Let me know if I am missing a piece.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] CaoManhDat commented on a change in pull request
#1167: SOLR-13845: DELETEREPLICA API by count and type
Posted by GitBox <gi...@apache.org>.
CaoManhDat commented on a change in pull request #1167: SOLR-13845: DELETEREPLICA API by count and type
URL: https://github.com/apache/lucene-solr/pull/1167#discussion_r381005728
##########
File path: solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java
##########
@@ -170,6 +170,58 @@ public void deleteReplicaAndVerifyDirectoryCleanup() throws Exception {
assertFalse("DataDirectory still exists", Files.exists(Paths.get(coreStatus.getDataDirectory())));
}
+ @Test
+ public void deleteReplicaByCountWithType() throws Exception {
+
+ final String collectionName = "deleteByCountWithType";
+
+ Create req = CollectionAdminRequest.createCollection(collectionName, "conf", 1, 2, 0, 2);
Review comment:
Should we do some randomization here so TLOG replica is also get tested?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] CaoManhDat commented on a change in pull request
#1167: SOLR-13845: DELETEREPLICA API by count and type
Posted by GitBox <gi...@apache.org>.
CaoManhDat commented on a change in pull request #1167: SOLR-13845: DELETEREPLICA API by count and type
URL: https://github.com/apache/lucene-solr/pull/1167#discussion_r380999083
##########
File path: solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
##########
@@ -2298,6 +2299,20 @@ public static DeleteReplica deleteReplicasFromAllShards(String collection, int c
return new DeleteReplica(collection, count);
}
+ public static DeleteReplica deleteReplica(String collection, String shard, int count, Replica.Type type) {
+ return new DeleteReplica(collection, checkNotNull(CoreAdminParams.SHARD, shard), count, type);
+ }
+ /**
Review comment:
may be new line here.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] CaoManhDat commented on a change in pull request
#1167: SOLR-13845: DELETEREPLICA API by count and type
Posted by GitBox <gi...@apache.org>.
CaoManhDat commented on a change in pull request #1167: SOLR-13845: DELETEREPLICA API by count and type
URL: https://github.com/apache/lucene-solr/pull/1167#discussion_r380999461
##########
File path: solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
##########
@@ -2326,6 +2342,20 @@ private DeleteReplica(String collection, int count) {
this.count = count;
}
+ private DeleteReplica(String collection, String shard, int count, Replica.Type type) {
+ super(CollectionAction.DELETEREPLICA, collection);
+ this.shard = shard;
+ this.count = count;
+ this.type = type;
+ }
+
+ private DeleteReplica(String collection, int count, Replica.Type type) {
+ super(CollectionAction.DELETEREPLICA, collection);
+ this.count = count;
+ this.type = type;
+ }
+
+
Review comment:
may be remove 1 new line here?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] CaoManhDat commented on a change in pull request
#1167: SOLR-13845: DELETEREPLICA API by count and type
Posted by GitBox <gi...@apache.org>.
CaoManhDat commented on a change in pull request #1167: SOLR-13845: DELETEREPLICA API by count and type
URL: https://github.com/apache/lucene-solr/pull/1167#discussion_r381005466
##########
File path: solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java
##########
@@ -170,6 +170,58 @@ public void deleteReplicaAndVerifyDirectoryCleanup() throws Exception {
assertFalse("DataDirectory still exists", Files.exists(Paths.get(coreStatus.getDataDirectory())));
}
+ @Test
+ public void deleteReplicaByCountWithType() throws Exception {
+
+ final String collectionName = "deleteByCountWithType";
+
+ Create req = CollectionAdminRequest.createCollection(collectionName, "conf", 1, 2, 0, 2);
+ req.setMaxShardsPerNode(2);
+ req.process(cluster.getSolrClient());
+ waitForState("Expected a single shard with six replicas", collectionName, clusterShape(1, 4));
+
+ CollectionAdminRequest.deleteReplicasFromShard(collectionName, "shard1", 1, Replica.Type.NRT).process(cluster.getSolrClient());
+ waitForState("Expected a single shard with a single NRT replica", collectionName, clusterShape(1, 1, Replica.Type.NRT));
+ waitForState("Expected a single shard with two PULL replicas", collectionName, clusterShape(1, 2, Replica.Type.PULL));
+
+ CollectionAdminRequest.deleteReplicasFromShard(collectionName, "shard1", 2, Replica.Type.PULL).process(cluster.getSolrClient());
+ waitForState("Expected a single shard with a single PULL replica", collectionName, clusterShape(1, 0, Replica.Type.PULL));
Review comment:
I think this message is not correct, we are expecting a shard with 0 pull replica
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] anshumg commented on a change in pull request #1167:
SOLR-13845: DELETEREPLICA API by count and type
Posted by GitBox <gi...@apache.org>.
anshumg commented on a change in pull request #1167: SOLR-13845: DELETEREPLICA API by count and type
URL: https://github.com/apache/lucene-solr/pull/1167#discussion_r367158755
##########
File path: solr/core/src/java/org/apache/solr/cloud/api/collections/DeleteReplicaCmd.java
##########
@@ -164,21 +168,31 @@ void deleteReplicaBasedOnCount(ClusterState clusterState,
/**
* Pick replicas to be deleted. Avoid picking the leader.
*/
- private Set<String> pickReplicasTobeDeleted(Slice slice, String shard, String collectionName, int count) {
- validateReplicaAvailability(slice, shard, collectionName, count);
+ private Set<String> pickReplicasTobeDeleted(Slice slice, String shard, String collectionName, int count, Replica.Type type) {
+ validateReplicaAvailability(slice, shard, collectionName, count, type);
Collection<Replica> allReplicas = slice.getReplicas();
Set<String> replicasToBeRemoved = new HashSet<String>();
Replica leader = slice.getLeader();
- for (Replica replica: allReplicas) {
+ for (Replica replica : allReplicas) {
if (count == 0) {
break;
}
//Try avoiding to pick up the leader to minimize activity on the cluster.
if (leader.getCoreName().equals(replica.getCoreName())) {
continue;
}
+ // if type is not null then only verify
+ if (type != null && !replica.getType().equals(type)) {
+ continue;
+ }
replicasToBeRemoved.add(replica.getName());
- count --;
+ count--;
+ }
+ // pick the leader if no options left when type is passed
+ if (count == 1) {
Review comment:
This is more complicated in my opinion than it looks.
You don't want to delete the only remaining replica that can be the leader. I'll take a better look at this tonight.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] CaoManhDat commented on a change in pull request
#1167: SOLR-13845: DELETEREPLICA API by count and type
Posted by GitBox <gi...@apache.org>.
CaoManhDat commented on a change in pull request #1167: SOLR-13845: DELETEREPLICA API by count and type
URL: https://github.com/apache/lucene-solr/pull/1167#discussion_r380999083
##########
File path: solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
##########
@@ -2298,6 +2299,20 @@ public static DeleteReplica deleteReplicasFromAllShards(String collection, int c
return new DeleteReplica(collection, count);
}
+ public static DeleteReplica deleteReplica(String collection, String shard, int count, Replica.Type type) {
+ return new DeleteReplica(collection, checkNotNull(CoreAdminParams.SHARD, shard), count, type);
+ }
+ /**
Review comment:
may be new line here.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] CaoManhDat commented on a change in pull request
#1167: SOLR-13845: DELETEREPLICA API by count and type
Posted by GitBox <gi...@apache.org>.
CaoManhDat commented on a change in pull request #1167: SOLR-13845: DELETEREPLICA API by count and type
URL: https://github.com/apache/lucene-solr/pull/1167#discussion_r380999688
##########
File path: solr/core/src/java/org/apache/solr/cloud/api/collections/DeleteReplicaCmd.java
##########
@@ -164,21 +168,31 @@ void deleteReplicaBasedOnCount(ClusterState clusterState,
/**
* Pick replicas to be deleted. Avoid picking the leader.
*/
- private Set<String> pickReplicasTobeDeleted(Slice slice, String shard, String collectionName, int count) {
- validateReplicaAvailability(slice, shard, collectionName, count);
+ private Set<String> pickReplicasTobeDeleted(Slice slice, String shard, String collectionName, int count, Replica.Type type) {
+ validateReplicaAvailability(slice, shard, collectionName, count, type);
Collection<Replica> allReplicas = slice.getReplicas();
Set<String> replicasToBeRemoved = new HashSet<String>();
Replica leader = slice.getLeader();
- for (Replica replica: allReplicas) {
+ for (Replica replica : allReplicas) {
if (count == 0) {
break;
}
//Try avoiding to pick up the leader to minimize activity on the cluster.
if (leader.getCoreName().equals(replica.getCoreName())) {
continue;
}
+ // if type is not null then only verify
+ if (type != null && !replica.getType().equals(type)) {
+ continue;
+ }
replicasToBeRemoved.add(replica.getName());
- count --;
+ count--;
+ }
+ // pick the leader if no options left when type is passed
Review comment:
I think we should get rid of this part for this issue. And open another one if you have idea or case to support this.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] CaoManhDat commented on a change in pull request
#1167: SOLR-13845: DELETEREPLICA API by count and type
Posted by GitBox <gi...@apache.org>.
CaoManhDat commented on a change in pull request #1167: SOLR-13845: DELETEREPLICA API by count and type
URL: https://github.com/apache/lucene-solr/pull/1167#discussion_r380999227
##########
File path: solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java
##########
@@ -2298,6 +2299,20 @@ public static DeleteReplica deleteReplicasFromAllShards(String collection, int c
return new DeleteReplica(collection, count);
}
+ public static DeleteReplica deleteReplica(String collection, String shard, int count, Replica.Type type) {
+ return new DeleteReplica(collection, checkNotNull(CoreAdminParams.SHARD, shard), count, type);
+ }
+ /**
Review comment:
may be new line here
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene-solr] CaoManhDat commented on a change in pull request
#1167: SOLR-13845: DELETEREPLICA API by count and type
Posted by GitBox <gi...@apache.org>.
CaoManhDat commented on a change in pull request #1167: SOLR-13845: DELETEREPLICA API by count and type
URL: https://github.com/apache/lucene-solr/pull/1167#discussion_r381005608
##########
File path: solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java
##########
@@ -170,6 +170,58 @@ public void deleteReplicaAndVerifyDirectoryCleanup() throws Exception {
assertFalse("DataDirectory still exists", Files.exists(Paths.get(coreStatus.getDataDirectory())));
}
+ @Test
+ public void deleteReplicaByCountWithType() throws Exception {
+
+ final String collectionName = "deleteByCountWithType";
+
+ Create req = CollectionAdminRequest.createCollection(collectionName, "conf", 1, 2, 0, 2);
+ req.setMaxShardsPerNode(2);
+ req.process(cluster.getSolrClient());
+ waitForState("Expected a single shard with six replicas", collectionName, clusterShape(1, 4));
+
+ CollectionAdminRequest.deleteReplicasFromShard(collectionName, "shard1", 1, Replica.Type.NRT).process(cluster.getSolrClient());
+ waitForState("Expected a single shard with a single NRT replica", collectionName, clusterShape(1, 1, Replica.Type.NRT));
+ waitForState("Expected a single shard with two PULL replicas", collectionName, clusterShape(1, 2, Replica.Type.PULL));
+
+ CollectionAdminRequest.deleteReplicasFromShard(collectionName, "shard1", 2, Replica.Type.PULL).process(cluster.getSolrClient());
+ waitForState("Expected a single shard with a single PULL replica", collectionName, clusterShape(1, 0, Replica.Type.PULL));
+
+ SolrException e = expectThrows(SolrException.class,
+ "Can't delete the last replica by count",
+ () -> CollectionAdminRequest.deleteReplicasFromShard(collectionName, "shard1", 1, Replica.Type.NRT).process(cluster.getSolrClient())
+ );
+ assertEquals(SolrException.ErrorCode.BAD_REQUEST.code, e.code());
+ assertTrue(e.getMessage().contains("There are lesser num replicas or qualified leaders requested to be deleted than are available in shard/collection"));
+ DocCollection docCollection = getCollectionState(collectionName);
+ // We know that since leaders are preserved, PULL replicas should not be left alone in the shard
Review comment:
this one need updated too.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org