You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by is...@apache.org on 2021/02/12 16:57:12 UTC

[lucene-solr] branch jira/solr15138 updated: Send REFRESH_COLLECTIONS message even after a failure

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

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


The following commit(s) were added to refs/heads/jira/solr15138 by this push:
     new b63bb2c  Send REFRESH_COLLECTIONS message even after a failure
b63bb2c is described below

commit b63bb2ccd804b85b543e72be7803864ec1b75727
Author: Ishan Chattopadhyaya <is...@apache.org>
AuthorDate: Fri Feb 12 22:26:51 2021 +0530

    Send REFRESH_COLLECTIONS message even after a failure
---
 .../solr/cloud/api/collections/CreateCollectionCmd.java  | 16 ++++++++--------
 .../apache/solr/cloud/CreateCollectionCleanupTest.java   |  2 +-
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java
index b8e8431..c652ccd 100644
--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java
+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java
@@ -103,7 +103,7 @@ public class CreateCollectionCmd implements OverseerCollectionMessageHandler.Cmd
     final boolean waitForFinalState = message.getBool(WAIT_FOR_FINAL_STATE, false);
     final String alias = message.getStr(ALIAS, collectionName);
     log.info("Create collection {}", collectionName);
-    final boolean isPrs = message.getBool(DocCollection.PER_REPLICA_STATE, false);
+    final boolean isPRS = message.getBool(DocCollection.PER_REPLICA_STATE, false);
     if (clusterState.hasCollection(collectionName)) {
       throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "collection already exists: " + collectionName);
     }
@@ -145,7 +145,7 @@ public class CreateCollectionCmd implements OverseerCollectionMessageHandler.Cmd
 
       createCollectionZkNode(stateManager, collectionName, collectionParams);
 
-      if(isPrs) {
+      if (isPRS) {
         ZkWriteCommand command = new ClusterStateMutator(ocmh.cloudManager).createCollection(clusterState, message);
         byte[] data = Utils.toJSON(Collections.singletonMap(collectionName, command.collection));
         ocmh.zkStateReader.getZkClient().create(collectionPath, data, CreateMode.PERSISTENT, true);
@@ -219,7 +219,7 @@ public class CreateCollectionCmd implements OverseerCollectionMessageHandler.Cmd
             ZkStateReader.NODE_NAME_PROP, nodeName,
             ZkStateReader.REPLICA_TYPE, replicaPosition.type.name(),
             CommonAdminParams.WAIT_FOR_FINAL_STATE, Boolean.toString(waitForFinalState));
-        if(isPrs) {
+        if (isPRS) {
           ZkWriteCommand command = new SliceMutator(ocmh.cloudManager).addReplica(clusterState, props);
           byte[] data = Utils.toJSON(Collections.singletonMap(collectionName, command.collection));
 //        log.info("collection updated : {}", new String(data, StandardCharsets.UTF_8));
@@ -262,7 +262,7 @@ public class CreateCollectionCmd implements OverseerCollectionMessageHandler.Cmd
 
       // wait for all replica entries to be created
       Map<String, Replica> replicas ;
-      if(isPrs) {
+      if (isPRS) {
         replicas = new ConcurrentHashMap<>();
         newColl.getSlices().stream().flatMap(slice -> slice.getReplicas().stream())
                 .filter(r -> coresToCreate.containsKey(r.getCoreName()))       // Only the elements that were asked for...
@@ -280,7 +280,7 @@ public class CreateCollectionCmd implements OverseerCollectionMessageHandler.Cmd
       shardRequestTracker.processResponses(results, shardHandler, false, null, Collections.emptySet());
       @SuppressWarnings({"rawtypes"})
       boolean failure = results.get("failure") != null && ((SimpleOrderedMap)results.get("failure")).size() > 0;
-      if(isPrs) {
+      if(isPRS) {
         TimeOut timeout = new TimeOut(Integer.getInteger("solr.waitToSeeReplicasInStateTimeoutSeconds", 120), TimeUnit.SECONDS, timeSource); // could be a big cluster
         PerReplicaStates prs = PerReplicaStates.fetch(collectionPath, ocmh.zkStateReader.getZkClient(), null);
         while (!timeout.hasTimedOut()) {
@@ -290,12 +290,12 @@ public class CreateCollectionCmd implements OverseerCollectionMessageHandler.Cmd
         }
         if (prs.allActive()) {
           // we have successfully found all replicas to be ACTIVE
-          // Now ask Overseer to fetch the latest state of collection
-          // from ZK
-          ocmh.overseer.submit(new RefreshCollectionMessage(collectionName));
         } else {
           failure = true;
         }
+        // Now ask Overseer to fetch the latest state of collection
+        // from ZK
+        ocmh.overseer.submit(new RefreshCollectionMessage(collectionName));
       }
       if (failure) {
         // Let's cleanup as we hit an exception
diff --git a/solr/core/src/test/org/apache/solr/cloud/CreateCollectionCleanupTest.java b/solr/core/src/test/org/apache/solr/cloud/CreateCollectionCleanupTest.java
index b8c5b42..11e0055 100644
--- a/solr/core/src/test/org/apache/solr/cloud/CreateCollectionCleanupTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/CreateCollectionCleanupTest.java
@@ -100,7 +100,7 @@ public class CreateCollectionCleanupTest extends SolrCloudTestCase {
     assertThat(CollectionAdminRequest.listCollections(cloudClient), not(hasItem(collectionName)));
     
     // Create a collection that would fail
-    CollectionAdminRequest.Create create = CollectionAdminRequest.createCollection(collectionName,"conf1",1,1);
+    CollectionAdminRequest.Create create = CollectionAdminRequest.createCollection(collectionName,"conf1",1,1).setPerReplicaState(random().nextBoolean());
 
     Properties properties = new Properties();
     Path tmpDir = createTempDir();