You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2020/09/08 01:26:13 UTC

[lucene-solr] branch reference_impl_dev updated: @792 Bit of cleaning up the previous.

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

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


The following commit(s) were added to refs/heads/reference_impl_dev by this push:
     new 5e12777  @792 Bit of cleaning up the previous.
5e12777 is described below

commit 5e12777baa1cf9f5fe921cd8180f7a8e1a20e3ff
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Mon Sep 7 20:12:46 2020 -0500

    @792 Bit of cleaning up the previous.
---
 .../java/org/apache/solr/core/CoreContainer.java   | 38 +++++++++++++--
 .../src/java/org/apache/solr/core/ZkContainer.java | 56 ++++++++++++----------
 .../java/org/apache/solr/handler/IndexFetcher.java |  6 +--
 .../solrj/impl/CloudHttp2SolrClientTest.java       |  1 +
 4 files changed, 67 insertions(+), 34 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
index 8b37605..5a57683 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -869,7 +869,8 @@ public class CoreContainer implements Closeable {
 //              metricManager.registry(SolrMetricManager.getRegistryName(SolrInfoBean.Group.node)),
 //              SolrMetricManager.mkName("coreLoadExecutor", SolrInfoBean.Category.CONTAINER.toString(), "threadPool"));
       final List<Future<SolrCore>> futures = new ArrayList<>();
-      try {
+      Set<Future> zkRegFutures = null;
+    try {
         List<CoreDescriptor> cds = coresLocator.discover(this);
         if (isZooKeeperAware()) {
           // sort the cores if it is in SolrCloud. In standalone node the order does not matter
@@ -877,9 +878,11 @@ public class CoreContainer implements Closeable {
               .init(zkSys.zkController, cds);
           cds = new ArrayList<>(cds);// make a copy
           Collections.sort(cds, coreComparator::compare);
+          zkRegFutures = ConcurrentHashMap.newKeySet(cds.size());
         }
         checkForDuplicateCoreNames(cds);
         status |= CORE_DISCOVERY_COMPLETE;
+
         try (ParWork register = new ParWork(this)) {
           for (final CoreDescriptor cd : cds) {
             if (cd.isTransient() || !cd.isLoadOnStartup()) {
@@ -888,6 +891,7 @@ public class CoreContainer implements Closeable {
               solrCores.markCoreAsLoading(cd);
             }
             if (cd.isLoadOnStartup()) {
+              Set<Future> finalZkRegFutures = zkRegFutures;
               futures.add(solrCoreLoadExecutor.submit(() -> {
                 SolrCore core;
                 try {
@@ -901,7 +905,7 @@ public class CoreContainer implements Closeable {
                   }
                 }
                 register.collect("registerCoreInZk", () -> {
-                  zkSys.registerInZk(core, false);
+                  finalZkRegFutures.add(zkSys.registerInZk(core, false));
                 });
                 return core;
               }));
@@ -923,7 +927,17 @@ public class CoreContainer implements Closeable {
             } catch (ExecutionException e) {
               log.error("Error waiting for SolrCore to be loaded on startup", e.getCause());
             }
-
+          }
+          if (isZooKeeperAware()) {
+            for (Future<SolrCore> future : zkRegFutures) {
+              try {
+                future.get();
+              } catch (InterruptedException e) {
+                ParWork.propegateInterrupt(e);
+              } catch (ExecutionException e) {
+                log.error("Error waiting for SolrCore to be loaded on startup", e.getCause());
+              }
+            }
           }
         }
       }
@@ -1217,14 +1231,28 @@ public class CoreContainer implements Closeable {
     if (old == null || old == core) {
       if (log.isDebugEnabled()) log.debug("registering core: " + cd.getName());
       if (registerInZk) {
-        zkSys.registerInZk(core, skipRecovery);
+        try {
+          zkSys.registerInZk(core, skipRecovery).get();
+        } catch (InterruptedException e) {
+          ParWork.propegateInterrupt(e);
+          throw new SolrException(ErrorCode.SERVER_ERROR, e);
+        } catch (ExecutionException e) {
+          throw new SolrException(ErrorCode.SERVER_ERROR, e);
+        }
       }
       return null;
     } else {
       if (log.isDebugEnabled()) log.debug("replacing core: " + cd.getName());
       old.close();
       if (registerInZk) {
-        zkSys.registerInZk(core, skipRecovery);
+        try {
+          zkSys.registerInZk(core, skipRecovery).get();
+        } catch (InterruptedException e) {
+          ParWork.propegateInterrupt(e);
+          throw new SolrException(ErrorCode.SERVER_ERROR, e);
+        } catch (ExecutionException e) {
+          throw new SolrException(ErrorCode.SERVER_ERROR, e);
+        }
       }
       return old;
     }
diff --git a/solr/core/src/java/org/apache/solr/core/ZkContainer.java b/solr/core/src/java/org/apache/solr/core/ZkContainer.java
index b077a82..d5f3150 100644
--- a/solr/core/src/java/org/apache/solr/core/ZkContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/ZkContainer.java
@@ -26,6 +26,7 @@ import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
+import java.util.concurrent.Future;
 import java.util.concurrent.TimeoutException;
 import java.util.function.Predicate;
 import java.util.function.Supplier;
@@ -197,36 +198,39 @@ public class ZkContainer implements Closeable {
 
   public static volatile Predicate<CoreDescriptor> testing_beforeRegisterInZk;
 
-  public void registerInZk(final SolrCore core, boolean skipRecovery) {
-    MDCLoggingContext.setCore(core);
+  public Future registerInZk(final SolrCore core, boolean skipRecovery) {
     log.info("Register in ZooKeeper core={} skipRecovery={}", core.getName(), skipRecovery);
     CoreDescriptor cd = core.getCoreDescriptor(); // save this here - the core may not have it later
-
-    try {
-      try {
-        if (testing_beforeRegisterInZk != null) {
-          boolean didTrigger = testing_beforeRegisterInZk.test(cd);
-          if (log.isDebugEnabled()) {
-            log.debug("{} pre-zk hook", (didTrigger ? "Ran" : "Skipped"));
-          }
-        }
-        if (!core.getCoreContainer().isShutDown()) {
-          zkController.register(core.getName(), cd, skipRecovery);
-        }
-      } catch (Exception e) {
-        ParWork.propegateInterrupt(e);
-        SolrException exp = new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
+    Runnable r = () -> {
+        MDCLoggingContext.setCore(core);
         try {
-          zkController.publish(cd, Replica.State.DOWN);
-        } catch (Exception e1) {
-          ParWork.propegateInterrupt(e);
-          exp.addSuppressed(e1);
+          try {
+            if (testing_beforeRegisterInZk != null) {
+              boolean didTrigger = testing_beforeRegisterInZk.test(cd);
+              if (log.isDebugEnabled()) {
+                log.debug("{} pre-zk hook", (didTrigger ? "Ran" : "Skipped"));
+              }
+            }
+            if (!core.getCoreContainer().isShutDown()) {
+              zkController.register(core.getName(), cd, skipRecovery);
+            }
+          } catch (Exception e) {
+            ParWork.propegateInterrupt(e);
+            SolrException exp = new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
+            try {
+              zkController.publish(cd, Replica.State.DOWN);
+            } catch (Exception e1) {
+              ParWork.propegateInterrupt(e);
+              exp.addSuppressed(e1);
+            }
+            throw exp;
+          }
+        } finally {
+          MDCLoggingContext.clear();
         }
-        throw exp;
-      }
-    } finally {
-      MDCLoggingContext.clear();
-    }
+      };
+     return ParWork.getMyPerThreadExecutor().submit(r); // ### expert usage
+
   }
   
   public ZkController getZkController() {
diff --git a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
index 77ac860..d7cb760 100644
--- a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
+++ b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
@@ -1879,9 +1879,9 @@ public class IndexFetcher {
       params.set(CommonParams.QT, ReplicationHandler.PATH);
       //add the version to download. This is used to reserve the download
       params.set(solrParamOutput, fileName);
-      if (useInternalCompression) {
-        params.set(COMPRESSION, "true");
-      }
+//      if (useInternalCompression) {
+//        params.set(COMPRESSION, "true");
+//      }
       //use checksum
       if (this.includeChecksum) {
         params.set(CHECKSUM, true);
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java
index e629dec..4477496 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java
@@ -929,6 +929,7 @@ public class CloudHttp2SolrClientTest extends SolrCloudTestCase {
    */
   @Test
   // commented 15-Sep-2018 @LuceneTestCase.BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // 2-Aug-2018
+  @Nightly
   public void preferReplicaTypesTest() throws Exception {
 
     String collectionName = "replicaTypesTestColl";