Apache Lucene open-source search software
SOLR-5516: Try only waiting if we are a replacement leader and waiting a bit longer.
Mark Robert Miller2cc87df6ef44
diff --git a/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java b/solr/core/src/java/org/apache/solr/cloud/ElectionContext.javaindex 22cb75cab60..314bd1094f6 100644--- a/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java+++ b/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java@@ -185,6 +185,17 @@ final class ShardLeaderElectionContext extends ShardLeaderElectionContextBase {// we are going to attempt to be the leader// first cancel any current recoverycore.getUpdateHandler().getSolrCoreState().cancelRecovery();++ if (weAreReplacement) {+ // wait a moment for any floating updates to finish+ try {+ Thread.sleep(2500);+ } catch (InterruptedException e) {+ Thread.currentThread().interrupt();+ throw new SolrException(ErrorCode.SERVICE_UNAVAILABLE, e);+ }+ }+boolean success = false;try {success = syncStrategy.sync(zkController, core, leaderProps);diff --git a/solr/core/src/java/org/apache/solr/cloud/SyncStrategy.java b/solr/core/src/java/org/apache/solr/cloud/SyncStrategy.javaindex 0b5a67a44df..a3c04cfa24c 100644--- a/solr/core/src/java/org/apache/solr/cloud/SyncStrategy.java+++ b/solr/core/src/java/org/apache/solr/cloud/SyncStrategy.java@@ -94,13 +94,7 @@ public class SyncStrategy {log.error("No UpdateLog found - cannot sync");return false;}- // wait a second for any floating updates to finish- try {- Thread.sleep(1500);- } catch (InterruptedException e) {- Thread.currentThread().interrupt();- throw new SolrException(ErrorCode.SERVICE_UNAVAILABLE, e);- }+success = syncReplicas(zkController, core, leaderProps);} finally {SolrRequestInfo.clearRequestInfo();