lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From da...@apache.org
Subject lucene-solr:branch_7x: SOLR-12051: Adding error log in case of data loss
Date Sat, 10 Mar 2018 00:22:28 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/branch_7x 4d15ad1cb -> 4abdb2466


SOLR-12051: Adding error log in case of data loss


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

Branch: refs/heads/branch_7x
Commit: 4abdb24667f28777be512047bb012a7346d8039b
Parents: 4d15ad1
Author: Cao Manh Dat <datcm@apache.org>
Authored: Sat Mar 10 07:20:05 2018 +0700
Committer: Cao Manh Dat <datcm@apache.org>
Committed: Sat Mar 10 07:21:29 2018 +0700

----------------------------------------------------------------------
 .../src/java/org/apache/solr/cloud/ElectionContext.java     | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/4abdb246/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java b/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java
index a7c21b4..7d64717 100644
--- a/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java
+++ b/solr/core/src/java/org/apache/solr/cloud/ElectionContext.java
@@ -347,6 +347,7 @@ final class ShardLeaderElectionContext extends ShardLeaderElectionContextBase
{
       
       Replica.Type replicaType;
       String coreNodeName;
+      boolean setTermToMax = false;
       try (SolrCore core = cc.getCore(coreName)) {
         
         if (core == null) {
@@ -365,9 +366,11 @@ final class ShardLeaderElectionContext extends ShardLeaderElectionContextBase
{
         ZkShardTerms zkShardTerms = zkController.getShardTerms(collection, shardId);
         if (zkShardTerms.registered(coreNodeName) && !zkShardTerms.canBecomeLeader(coreNodeName))
{
           if (!waitForEligibleBecomeLeaderAfterTimeout(zkShardTerms, coreNodeName, leaderVoteWait))
{
-            log.info("Can't become leader, term of replica {} less than leader", coreNodeName);
             rejoinLeaderElection(core);
             return;
+          } else {
+            // only log an error if this replica win the election
+            setTermToMax = true;
           }
         }
 
@@ -470,7 +473,9 @@ final class ShardLeaderElectionContext extends ShardLeaderElectionContextBase
{
             }
           }
           // in case of leaderVoteWait timeout, a replica with lower term can win the election
-          if (zkController.getShardTerms(collection, shardId).registered(coreNodeName)) {
+          if (setTermToMax) {
+            log.error("WARNING: Potential data loss -- Replica {} became leader after timeout
(leaderVoteWait) " +
+                "without being up-to-date with the previous leader", coreNodeName);
             zkController.getShardTerms(collection, shardId).setTermEqualsToLeader(coreNodeName);
           }
           super.runLeaderProcess(weAreReplacement, 0);


Mime
View raw message