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 17:20:35 UTC

[lucene-solr] branch reference_impl_dev updated: @1232 Send the recovery lock into the recovery strat.

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 0e9826b  @1232 Send the recovery lock into the recovery strat.
0e9826b is described below

commit 0e9826bf85b271c672b1fdb828215b559c3df385
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Mon Nov 16 11:20:05 2020 -0600

    @1232 Send the recovery lock into the recovery strat.
---
 solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java | 10 ++++++++++
 .../src/java/org/apache/solr/update/DefaultSolrCoreState.java  |  6 ++----
 2 files changed, 12 insertions(+), 4 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 d3ca1b6..ae4ac42 100644
--- a/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
+++ b/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
@@ -72,6 +72,7 @@ import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.locks.ReentrantLock;
 
 /**
  * This class may change in future and customisations are not supported between versions in terms of API or back compat
@@ -83,6 +84,11 @@ public class RecoveryStrategy implements Runnable, Closeable {
 
   private volatile CountDownLatch latch;
   private volatile ReplicationHandler replicationHandler;
+  private volatile ReentrantLock recoveryLock;
+
+  public final void setRecoveryLock(ReentrantLock recoveryLock) {
+    this.recoveryLock = recoveryLock;
+  }
 
   public static class Builder implements NamedListInitializedPlugin {
     private NamedList args;
@@ -356,6 +362,10 @@ public class RecoveryStrategy implements Runnable, Closeable {
       ParWork.propagateInterrupt(e);
       log.error("", e);
       return;
+    } finally {
+      try {
+        recoveryLock.unlock();
+      } catch (NullPointerException e) {}
     }
 
   }
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 b356eed..b2b54a5 100644
--- a/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java
+++ b/solr/core/src/java/org/apache/solr/update/DefaultSolrCoreState.java
@@ -342,7 +342,7 @@ public final class DefaultSolrCoreState extends SolrCoreState implements Recover
         // we check to see if there is already one waiting to go
         // after the current one, and if there is, bail
         boolean locked = recoveryLock.tryLock();
-        try {
+
           if (!locked && recoveryWaiting.get() > 0) {
             return;
           }
@@ -370,14 +370,12 @@ public final class DefaultSolrCoreState extends SolrCoreState implements Recover
           recoveryThrottle.markAttemptingAction();
 
           recoveryStrat = recoveryStrategyBuilder.create(core.getCoreContainer(), core.getCoreDescriptor(), DefaultSolrCoreState.this);
+          recoveryStrat.setRecoveryLock(recoveryLock);
           recoveryStrat.setRecoveringAfterStartup(recoveringAfterStartup);
 
           log.info("Running recovery");
           recoveryStrat.run();
 
-        } finally {
-          if (recoveryLock.isHeldByCurrentThread()) recoveryLock.unlock();
-        }
       } catch (AlreadyClosedException e) {
 
       } catch (Exception e) {