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:06 UTC

[lucene-solr] 15/17: Refresh the particular PRS collection instead of all of them

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 c1184ac83cb64dd94c26f7a78b7313aaab1247f1
Author: Ishan Chattopadhyaya <is...@apache.org>
AuthorDate: Wed Feb 10 22:03:44 2021 +0530

    Refresh the particular PRS collection instead of all of them
---
 .../src/java/org/apache/solr/cloud/Overseer.java   | 22 +++++++++++++++-------
 .../cloud/api/collections/CreateCollectionCmd.java |  6 ++----
 2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/cloud/Overseer.java b/solr/core/src/java/org/apache/solr/cloud/Overseer.java
index 7c5834b..9ec72a0 100644
--- a/solr/core/src/java/org/apache/solr/cloud/Overseer.java
+++ b/solr/core/src/java/org/apache/solr/cloud/Overseer.java
@@ -152,8 +152,8 @@ public class Overseer implements SolrCloseable {
       return workQueue.getZkStats();
     }
 
-    private boolean refreshClusterState = false;
-
+    Set<String> refreshCollections = Collections.synchronizedSet(new HashSet<String>());
+    
     @Override
     public void run() {
       MDCLoggingContext.setNode(zkController.getNodeName() );
@@ -170,7 +170,7 @@ public class Overseer implements SolrCloseable {
       try {
         ZkStateWriter zkStateWriter = null;
         ClusterState clusterState = null;
-        refreshClusterState = true; // let's refresh in the first iteration
+        boolean refreshClusterState = true; // let's refresh in the first iteration
 
         // we write updates in batch, but if an exception is thrown when writing new clusterstate,
         // we do not sure which message is bad message, therefore we will re-process node one by one
@@ -187,9 +187,17 @@ public class Overseer implements SolrCloseable {
           }
 
           //TODO consider removing 'refreshClusterState' and simply check if clusterState is null
-          if (refreshClusterState) {
+          if (refreshClusterState || refreshCollections.size() != 0) {
             try {
-              reader.forciblyRefreshAllClusterStateSlow();
+              if (refreshClusterState) {
+                reader.forciblyRefreshAllClusterStateSlow();
+              } else {
+                Set<String> collectionsToRefresh = new HashSet<>(refreshCollections);
+                for (String c: collectionsToRefresh) {
+                  reader.forceUpdateCollection(c);
+                  refreshCollections.remove(c);
+                }
+              }
               clusterState = reader.getClusterState();
               zkStateWriter = new ZkStateWriter(reader, stats);
               refreshClusterState = false;
@@ -309,8 +317,8 @@ public class Overseer implements SolrCloseable {
     }
 
     // nocommit: javadocs
-    public void refreshClusterState() {
-      refreshClusterState = true;
+    public void refreshClusterState(String collection) {
+      refreshCollections.add(collection);
     }
 
     // Return true whenever the exception thrown by ZkStateWriter is correspond
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 f1acaa4..ced2baa 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
@@ -18,7 +18,6 @@
 package org.apache.solr.cloud.api.collections;
 
 
-import javax.print.Doc;
 import java.io.IOException;
 import java.lang.invoke.MethodHandles;
 import java.nio.charset.StandardCharsets;
@@ -81,7 +80,6 @@ import org.apache.zookeeper.KeeperException.NoNodeException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static java.util.Collections.singletonMap;
 import static org.apache.solr.common.cloud.ZkStateReader.MAX_SHARDS_PER_NODE;
 import static org.apache.solr.common.cloud.ZkStateReader.NRT_REPLICAS;
 import static org.apache.solr.common.cloud.ZkStateReader.PULL_REPLICAS;
@@ -278,7 +276,7 @@ public class CreateCollectionCmd implements OverseerCollectionMessageHandler.Cmd
             // Since we're directly updating the state here, instead of doing it via a queue in the overseer,
             // we need to make sure that the cluster state updater used in the Overseer can see this update
             // upon refreshing itself
-            //((Overseer.ClusterStateUpdater) ocmh.overseer.getUpdaterThread().getThread()).refreshClusterState();
+            ((Overseer.ClusterStateUpdater) ocmh.overseer.getUpdaterThread().getThread()).refreshClusterState(collectionName);
 
             clusterState = clusterState.copyWith(collectionName, command.collection);
           } else {
@@ -345,7 +343,7 @@ public class CreateCollectionCmd implements OverseerCollectionMessageHandler.Cmd
         if (isPrs) {
           // Since we created this collection without some of the sub-operations going through the overseer queues,
           // we need to make sure that the cluster state in the overseer can see this collection upon refreshing itself
-          ((Overseer.ClusterStateUpdater) ocmh.overseer.getUpdaterThread().getThread()).refreshClusterState();
+          ((Overseer.ClusterStateUpdater) ocmh.overseer.getUpdaterThread().getThread()).refreshClusterState(collectionName);
         }
         // Emit a warning about production use of data driven functionality
         boolean defaultConfigSetUsed = message.getStr(COLL_CONF) == null ||