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/11/16 00:42:37 UTC

[lucene-solr] 02/02: @1218 Give SolrCore a start method so we know its fully constrcuted when stuff starts hitting it.

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

commit 506d231ee6aac749b1dcf47028c2c3989cae9070
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Sun Nov 15 18:39:16 2020 -0600

    @1218 Give SolrCore a start method so we know its fully constrcuted when stuff starts hitting it.
---
 .../java/org/apache/solr/core/CoreContainer.java   |  7 ++--
 .../src/java/org/apache/solr/core/SolrCore.java    | 43 ++++++++++++----------
 .../org/apache/solr/core/SolrResourceLoader.java   |  4 +-
 .../java/org/apache/solr/schema/IndexSchema.java   |  8 +---
 .../java/org/apache/solr/update/UpdateHandler.java |  5 ++-
 5 files changed, 34 insertions(+), 33 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 48ad264..7d74696 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -1334,7 +1334,8 @@ public class CoreContainer implements Closeable {
       ConfigSet coreConfig = coreConfigService.loadConfigSet(dcore);
       dcore.setConfigSetTrusted(coreConfig.isTrusted());
       if (log.isInfoEnabled()) {
-        log.info("Creating SolrCore '{}' using configuration from {}, trusted={}", dcore.getName(), coreConfig.getName(), dcore.isConfigSetTrusted());
+        log.info("Creating SolrCore '{}' using configuration from {} solrconfig={}, trusted={}", dcore.getName(),
+            coreConfig.getName(), coreConfig.getSolrConfig().getName(), dcore.isConfigSetTrusted());
       }
       try {
         if (isShutDown) {
@@ -1349,6 +1350,8 @@ public class CoreContainer implements Closeable {
       registerCore(dcore, core, isZooKeeperAware(), false);
       registered = true;
 
+      core.start();
+
       // always kick off recovery if we are in non-Cloud mode
       if (!isZooKeeperAware() && core.getUpdateHandler().getUpdateLog() != null) {
         core.getUpdateHandler().getUpdateLog().recoverFromLog();
@@ -1962,8 +1965,6 @@ public class CoreContainer implements Closeable {
       core = createFromDescriptor(desc, false); // This should throw an error if it fails.
     }
 
-
-
     core.open();
 
 
diff --git a/solr/core/src/java/org/apache/solr/core/SolrCore.java b/solr/core/src/java/org/apache/solr/core/SolrCore.java
index 06b3efe..e7e4b49 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java
@@ -731,7 +731,7 @@ public final class SolrCore implements SolrInfoBean, Closeable {
         cd.loadExtraProperties(); //Reload the extra properties
         coreMetricManager.close();
         core = new SolrCore(coreContainer, getName(), coreConfig, cd, getDataDir(), updateHandler, solrDelPolicy, currentCore, true);
-
+        core.start();
         // we open a new IndexWriter to pick up the latest config
         core.getUpdateHandler().getSolrCoreState().newIndexWriter(core, false);
         core.getSearcher(true, false, null, true);
@@ -1095,25 +1095,6 @@ public final class SolrCore implements SolrInfoBean, Closeable {
       this.ruleExpiryLock = new ReentrantLock();
       this.snapshotDelLock = new ReentrantLock();
 
-      // register any SolrInfoMBeans SolrResourceLoader initialized
-      //
-      // this must happen after the latch is released, because a JMX server impl may
-      // choose to block on registering until properties can be fetched from an MBean,
-      // and a SolrCoreAware MBean may have properties that depend on getting a Searcher
-      // from the core.
-      resourceLoader.inform(infoRegistry);
-
-      // Finally tell anyone who wants to know
-      resourceLoader.inform(resourceLoader);
-
-      resourceLoader.inform(this); // last call before the latch is released.
-
-      searcherReadyLatch.countDown();
-
-      // seed version buckets with max from index during core initialization ... requires a searcher!
-      //if (!reload) { // TODO: reload could move to a different index?
-        seedVersionBuckets();
-     // }
     } catch (Throwable e) {
       log.error("Error while creating SolrCore", e);
       // release the latch, otherwise we block trying to do the close. This
@@ -1142,6 +1123,28 @@ public final class SolrCore implements SolrInfoBean, Closeable {
     assert ObjectReleaseTracker.track(this);
   }
 
+  public void start() {
+    // register any SolrInfoMBeans SolrResourceLoader initialized
+    //
+    // this must happen after the latch is released, because a JMX server impl may
+    // choose to block on registering until properties can be fetched from an MBean,
+    // and a SolrCoreAware MBean may have properties that depend on getting a Searcher
+    // from the core.
+    resourceLoader.inform(infoRegistry);
+
+    // Finally tell anyone who wants to know
+    resourceLoader.inform(resourceLoader);
+
+    resourceLoader.inform(this); // last call before the latch is released.
+
+    searcherReadyLatch.countDown();
+
+    // seed version buckets with max from index during core initialization ... requires a searcher!
+    if (!isReloaded) { // TODO: reload could move to a different index?
+      seedVersionBuckets();
+    }
+  }
+
   public void seedVersionBuckets() {
     UpdateHandler uh = getUpdateHandler();
     if (uh != null && uh.getUpdateLog() != null) {
diff --git a/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java b/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java
index 26a119d..cb46e7b 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrResourceLoader.java
@@ -653,7 +653,7 @@ public class SolrResourceLoader implements ResourceLoader, Closeable {
               aware.inform(core);
             } catch (Exception e) {
               ParWork.propagateInterrupt("Exception informing for SolrCore", e);
-              throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Exception informing for SolrCore", e);
+              throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Exception informing for SolrCore: " + e.getMessage(), e);
             }
             waitingForCore.remove(aware);
           });
@@ -665,7 +665,7 @@ public class SolrResourceLoader implements ResourceLoader, Closeable {
   /**
    * Tell all {@link ResourceLoaderAware} instances about the loader
    */
-  public void inform(ResourceLoader loader) throws IOException {
+  public void inform(ResourceLoader loader) {
     while (waitingForResources.size() > 0) {
       try (ParWork worker = new ParWork(this, false, true)) {
         waitingForResources.forEach(r -> {
diff --git a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java b/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
index 9b876e6..b5b4532 100644
--- a/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
+++ b/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
@@ -281,12 +281,8 @@ public class IndexSchema {
     this(luceneVersion, resourceLoader, substitutableProperties);
 
     this.resourceName = Objects.requireNonNull(name);
-    try {
-      readSchema(is);
-      loader.inform(loader);
-    } catch (IOException e) {
-      throw new RuntimeException(e);
-    }
+    readSchema(is);
+    loader.inform(loader);
   }
 
   protected IndexSchema(Version luceneVersion, SolrResourceLoader loader, Properties substitutableProperties) {
diff --git a/solr/core/src/java/org/apache/solr/update/UpdateHandler.java b/solr/core/src/java/org/apache/solr/update/UpdateHandler.java
index 22164f5..c5a1348 100644
--- a/solr/core/src/java/org/apache/solr/update/UpdateHandler.java
+++ b/solr/core/src/java/org/apache/solr/update/UpdateHandler.java
@@ -167,10 +167,11 @@ UpdateHandler implements SolrInfoBean, Closeable {
       if (ourUpdateLog != null) {
         ulog = ourUpdateLog;
       } else {
-        if (core.getCoreContainer().isZooKeeperAware()) {
+        if (core.getCoreContainer().isZooKeeperAware() && (ulogPluginInfo == null || !ulogPluginInfo.isEnabled())) {
           // TODO: workaround rare test issue where updatelog is not found
-          ulog = new UpdateLog();
+          ourUpdateLog = new UpdateLog();
           ourUpdateLog.init(this, core);
+          ulog = ourUpdateLog;
         } else {
           ulog = null;
         }