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/08/17 23:12:03 UTC

[lucene-solr] 33/49: @547 We read the wind and the sky When the sun is high We sail the length of sea On the ocean breeze

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

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

commit 4caf98d7a56b9fba58a775d4753fad05a8cdfd63
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Sat Aug 15 15:23:30 2020 -0500

    @547 We read the wind and the sky
    When the sun is high
    We sail the length of sea
    On the ocean breeze
---
 .../src/java/org/apache/solr/core/SolrCore.java    | 29 ++++++++++++++++------
 .../solr/common/util/SolrQueuedThreadPool.java     | 17 ++++++++++---
 2 files changed, 36 insertions(+), 10 deletions(-)

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 32b47c2..80fe2e4 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrCore.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrCore.java
@@ -194,6 +194,7 @@ public final class SolrCore implements SolrInfoBean, Closeable {
   private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
   private static final Logger requestLog = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass().getName() + ".Request");
   private static final Logger slowLog = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass().getName() + ".SlowRequest");
+  private final boolean failedCreation;
 
   private volatile String name;
   private String logid; // used to show what name is set
@@ -956,6 +957,7 @@ public final class SolrCore implements SolrInfoBean, Closeable {
   private SolrCore(CoreContainer coreContainer, String name, ConfigSet configSet, CoreDescriptor coreDescriptor,
                   String dataDir, UpdateHandler updateHandler,
                   IndexDeletionPolicyWrapper delPolicy, SolrCore prev, boolean reload) {
+    boolean failedCreation1;
 
     assert ObjectReleaseTracker.track(searcherExecutor); // ensure that in unclean shutdown tests we still close this
     assert ObjectReleaseTracker.track(this);
@@ -1090,17 +1092,18 @@ public final class SolrCore implements SolrInfoBean, Closeable {
 
       resourceLoader.inform(this); // last call before the latch is released.
       latch.countDown();
+      failedCreation1 = false;
     } catch (Throwable e) {
       log.error("Error while creating SolrCore", e);
       // release the latch, otherwise we block trying to do the close. This
       // should be fine, since counting down on a latch of 0 is still fine
       latch.countDown();
       ParWork.propegateInterrupt(e);
-
+      failedCreation1 = true;
       try {
         // close down the searcher and any other resources, if it exists, as this
         // is not recoverable
-        onDeckSearchers.set(0);
+        //onDeckSearchers.set(0);
         close();
       } catch (Throwable t) {
         ParWork.propegateInterrupt("Error while closing", t);
@@ -1119,6 +1122,7 @@ public final class SolrCore implements SolrInfoBean, Closeable {
       //latch.countDown();
     }
 
+    this.failedCreation = failedCreation1;
     assert ObjectReleaseTracker.track(this);
   }
 
@@ -1664,11 +1668,22 @@ public final class SolrCore implements SolrInfoBean, Closeable {
 
         synchronized (searcherLock) {
           while (onDeckSearchers.get() > 0) {
-            try {
-              searcherLock.wait(10); // nocommit
-            } catch (InterruptedException e) {
-              // ParWork.propegateInterrupt(e);
-            } // nocommit
+            if (failedCreation) {
+              synchronized (searcherLock) {
+                for (RefCounted<SolrIndexSearcher> searcher : _searchers) {
+                  searcher.get().close();
+                }
+                for (RefCounted<SolrIndexSearcher> searcher : _realtimeSearchers) {
+                  searcher.get().close();
+                }
+              }
+            } else {
+              try {
+                searcherLock.wait(250); // nocommit
+              } catch (InterruptedException e) {
+                ParWork.propegateInterrupt(e);
+              } // nocommit
+            }
           }
         }
         return "wait for on deck searchers";
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/SolrQueuedThreadPool.java b/solr/solrj/src/java/org/apache/solr/common/util/SolrQueuedThreadPool.java
index f118aed..c6d7e15 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/SolrQueuedThreadPool.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/SolrQueuedThreadPool.java
@@ -25,6 +25,7 @@ import java.util.Locale;
 import java.util.Set;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.RejectedExecutionException;
 import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.TimeUnit;
@@ -667,11 +668,12 @@ public class SolrQueuedThreadPool extends ContainerLifeCycle implements ThreadFa
         try
         {
             Thread thread = _threadFactory.newThread(_runnable);
+            ParWork.getEXEC().execute(thread);
             if (LOG.isDebugEnabled())
                 LOG.debug("Starting {}", thread);
             _threads.add(thread);
             _lastShrink.set(System.nanoTime());
-            thread.start();
+            _runnable.waitForStart();
             started = true;
         }
         finally
@@ -824,7 +826,7 @@ public class SolrQueuedThreadPool extends ContainerLifeCycle implements ThreadFa
                 _tryExecutor);
     }
 
-    private final Runnable _runnable = new SolrQueuedThreadPool.Runner();
+    private final SolrQueuedThreadPool.Runner _runnable = new SolrQueuedThreadPool.Runner();
 
     /**
      * <p>Runs the given job in the {@link Thread#currentThread() current thread}.</p>
@@ -908,6 +910,7 @@ public class SolrQueuedThreadPool extends ContainerLifeCycle implements ThreadFa
 
     private class Runner implements Runnable
     {
+        CountDownLatch latch = new CountDownLatch(1);
         private Runnable idleJobPoll(long idleTimeout) throws InterruptedException
         {
             if (idleTimeout <= 0)
@@ -915,12 +918,20 @@ public class SolrQueuedThreadPool extends ContainerLifeCycle implements ThreadFa
             return _jobs.poll(idleTimeout, TimeUnit.MILLISECONDS);
         }
 
+        public void waitForStart() {
+            try {
+                latch.await();
+            } catch (InterruptedException e) {
+
+            }
+        }
+
         @Override
         public void run()
         {
             if (LOG.isDebugEnabled())
                 LOG.debug("Runner started for {}", SolrQueuedThreadPool.this);
-
+            latch.countDown();
             boolean idle = true;
             try
             {