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/07/22 14:40:22 UTC

[lucene-solr] 02/02: @296 Interrupt around log replay.

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 c4789e8802a1e80ad0db73b11a14026e9130f5a0
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Wed Jul 22 09:39:30 2020 -0500

    @296 Interrupt around log replay.
---
 solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java    | 5 ++++-
 .../src/java/org/apache/solr/update/DefaultSolrCoreState.java     | 2 +-
 .../src/java/org/apache/solr/common/util/OrderedExecutor.java     | 8 +++++---
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java b/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
index 29d96db..0c601f3 100644
--- a/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
+++ b/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
@@ -25,6 +25,7 @@ import java.util.List;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import net.sf.saxon.trans.Err;
@@ -928,10 +929,12 @@ public class RecoveryStrategy implements Runnable, Closeable {
       // wait for replay
       RecoveryInfo report;
       try {
-        report = future.get();
+        report = future.get(10, TimeUnit.MINUTES); // nocommit - how long? make configurable too
       } catch (InterruptedException e) {
         ParWork.propegateInterrupt(e);
         throw new InterruptedException();
+      } catch (TimeoutException e) {
+        throw new SolrException(ErrorCode.SERVER_ERROR, e);
       }
       if (report.failed) {
         SolrException.log(log, "Replay failed");
diff --git a/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java b/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java
index 7be3229..ef8e8da 100644
--- a/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java
+++ b/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java
@@ -398,7 +398,7 @@ public final class DefaultSolrCoreState extends SolrCoreState implements Recover
       }
       if (wait && recoveryStrat != null && recoveryFuture != null) {
         try {
-          recoveryFuture.get(10, TimeUnit.MINUTES);
+          recoveryFuture.get(10, TimeUnit.MINUTES); // nocommit - how long? make configurable too
         } catch (InterruptedException e) {
           ParWork.propegateInterrupt(e);
           throw new SolrException(ErrorCode.SERVER_ERROR, e);
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/OrderedExecutor.java b/solr/solrj/src/java/org/apache/solr/common/util/OrderedExecutor.java
index 2095146..7a863e5 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/OrderedExecutor.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/OrderedExecutor.java
@@ -24,6 +24,8 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.RejectedExecutionException;
 import java.util.concurrent.Semaphore;
 
+import org.apache.solr.common.ParWork;
+import org.apache.solr.common.SolrException;
 import org.apache.solr.common.util.ExecutorUtil;
 
 public class OrderedExecutor implements Executor {
@@ -57,8 +59,8 @@ public class OrderedExecutor implements Executor {
     try {
       sparseStripedLock.add(lockId);
     } catch (InterruptedException e) {
-      Thread.currentThread().interrupt();
-      return;
+      ParWork.propegateInterrupt(e);
+      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
     }
 
     try {
@@ -91,7 +93,7 @@ public class OrderedExecutor implements Executor {
 
   /** A set of locks by a key {@code T}, kind of like Google Striped but the keys are sparse/lazy. */
   private static class SparseStripedLock<T> {
-    private ConcurrentHashMap<T, CountDownLatch> map = new ConcurrentHashMap<>();
+    private ConcurrentHashMap<T, CountDownLatch> map = new ConcurrentHashMap<>(32);
     private final Semaphore sizeSemaphore;
 
     SparseStripedLock(int maxSize) {