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 2021/02/03 18:47:06 UTC
[lucene-solr] 06/08: @1322 If no one is is even on a live node,
makes no sense to wait.
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
commit 96936a4352f4ce93150ee00e61ec148280d0f09e
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Wed Feb 3 02:12:20 2021 -0600
@1322 If no one is is even on a live node, makes no sense to wait.
---
.../solr/cloud/ShardLeaderElectionContext.java | 34 +++++++++++++++++-----
1 file changed, 27 insertions(+), 7 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/cloud/ShardLeaderElectionContext.java b/solr/core/src/java/org/apache/solr/cloud/ShardLeaderElectionContext.java
index e87e1a1..5a2cbe7 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ShardLeaderElectionContext.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ShardLeaderElectionContext.java
@@ -146,15 +146,35 @@ final class ShardLeaderElectionContext extends ShardLeaderElectionContextBase {
} catch (Exception e) {
log.error("Exception while looking at refreshing shard terms", e);
}
-
+
if (zkShardTerms != null && zkShardTerms.registered(coreName) && !zkShardTerms.canBecomeLeader(coreName)) {
- if (!waitForEligibleBecomeLeaderAfterTimeout(zkShardTerms, coreName, leaderVoteWait)) {
- rejoinLeaderElection(core);
- return false;
- } else {
- // only log an error if this replica win the election
- setTermToMax = true;
+ boolean onlyLiveReplica = true;
+ DocCollection coll = zkController.zkStateReader.getClusterState().getCollectionOrNull(collection);
+
+ if (coll != null) {
+ Slice slice = coll.getSlice(shardId);
+ if (slice != null) {
+ for (Replica replica : slice) {
+ if (replica.getName().equals(coreName)) {
+ continue;
+ }
+ if (zkController.zkStateReader.isNodeLive(replica.getNodeName())) {
+ onlyLiveReplica = false;
+ break;
+ }
+ }
+ }
+ }
+
+ if (!onlyLiveReplica) {
+ if (!waitForEligibleBecomeLeaderAfterTimeout(zkShardTerms, coreName, leaderVoteWait)) {
+ rejoinLeaderElection(core);
+ return false;
+ }
}
+
+ // only log an error if this replica win the election
+ setTermToMax = true;
}
log.info("I may be the new leader - try and sync");