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/04/05 21:24:03 UTC

[lucene-solr] 12/17: fast collection creation

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

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

commit db9b52b468f111782c5d71a1fdf9c43b6b79eeb2
Author: noblepaul <no...@gmail.com>
AuthorDate: Tue Feb 9 23:54:20 2021 +1100

    fast collection creation
---
 .../solr/cloud/api/collections/CreateCollectionCmd.java       |  4 ++--
 .../api/collections/OverseerCollectionMessageHandler.java     | 11 ++++++++++-
 2 files changed, 12 insertions(+), 3 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 dbdf87c..b832825 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
@@ -183,7 +183,7 @@ public class CreateCollectionCmd implements OverseerCollectionMessageHandler.Cmd
       if (isPrs) {
         ZkWriteCommand command = new ClusterStateMutator(ocmh.cloudManager).createCollection(clusterState, message);
         byte[] data = Utils.toJSON(Collections.singletonMap(collectionName, command.collection));
-        log.info("collection created : {}", new String(data, StandardCharsets.UTF_8));
+//        log.info("collection created : {}", new String(data, StandardCharsets.UTF_8));
         zksr.getZkClient().create(ZkStateReader.getCollectionPath(collectionName), data, CreateMode.PERSISTENT, true);
         clusterState = clusterState.copyWith(collectionName, command.collection);
       } else {
@@ -333,7 +333,7 @@ public class CreateCollectionCmd implements OverseerCollectionMessageHandler.Cmd
         // We shouldn't be passing 'results' here for the cleanup as the response would then contain 'success'
         // element, which may be interpreted by the user as a positive ack
         ocmh.cleanupCollection(collectionName, new NamedList<Object>());
-        log.info("Cleaned up artifacts for failed create collection for [{}]", collectionName);
+//        log.info("Cleaned up artifacts for failed create collection for [{}]", collectionName);
         throw new SolrException(ErrorCode.BAD_REQUEST, "Underlying core creation failed while creating collection: " + collectionName);
       } else {
         log.debug("Finished create command on all shards for collection: {}", collectionName);
diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/OverseerCollectionMessageHandler.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/OverseerCollectionMessageHandler.java
index 3c474e5..2fecdb5 100644
--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/OverseerCollectionMessageHandler.java
+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/OverseerCollectionMessageHandler.java
@@ -687,7 +687,16 @@ public class OverseerCollectionMessageHandler implements OverseerMessageHandler,
     Map<String, Replica> result = new HashMap<>();
     TimeOut timeout = new TimeOut(Integer.getInteger("solr.waitToSeeReplicasInStateTimeoutSeconds", 120), TimeUnit.SECONDS, timeSource); // could be a big cluster
     while (true) {
-      DocCollection coll = zkStateReader.getClusterState().getCollection(collectionName);
+      DocCollection coll = zkStateReader.getClusterState().getCollectionOrNull(collectionName);
+      if(coll == null) {
+        if (timeout.hasTimedOut()) {
+          throw new SolrException(ErrorCode.SERVER_ERROR, "Timed out waiting to see all replicas: " + coreNames + " in cluster state. Last state: " + coll);
+        }
+
+        Thread.sleep(100);
+        continue;
+
+      }
       for (String coreName : coreNames) {
         if (result.containsKey(coreName)) continue;
         for (Slice slice : coll.getSlices()) {