You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by da...@apache.org on 2018/12/12 16:51:27 UTC

lucene-solr:jira/http2: Harderning localIsLeader check

Repository: lucene-solr
Updated Branches:
  refs/heads/jira/http2 95677534e -> 8e1e0e245


Harderning localIsLeader check


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/8e1e0e24
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/8e1e0e24
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/8e1e0e24

Branch: refs/heads/jira/http2
Commit: 8e1e0e245d8901ae9dd9929d93c2adfb942151c9
Parents: 9567753
Author: Cao Manh Dat <da...@apache.org>
Authored: Wed Dec 12 16:51:19 2018 +0000
Committer: Cao Manh Dat <da...@apache.org>
Committed: Wed Dec 12 16:51:19 2018 +0000

----------------------------------------------------------------------
 .../update/processor/DistributedUpdateProcessor.java    | 12 ++++++++++++
 1 file changed, 12 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8e1e0e24/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java b/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
index 868ae02..4f1e580 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
@@ -618,6 +618,18 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
       }
     }
 
+    int count = 0;
+    while (((isLeader && !localIsLeader) || (isSubShardLeader && !localIsLeader)) && count < 5) {
+      count++;
+      // re-getting localIsLeader since we published to ZK first before setting localIsLeader value
+      localIsLeader = cloudDesc.isLeader();
+      try {
+        Thread.sleep(500);
+      } catch (InterruptedException e) {
+        Thread.currentThread().interrupt();
+      }
+    }
+
     if ((isLeader && !localIsLeader) || (isSubShardLeader && !localIsLeader)) {
       log.error("ClusterState says we are the leader, but locally we don't think so");
       throw new SolrException(ErrorCode.SERVICE_UNAVAILABLE,