mirror of https://github.com/apache/lucene.git
SOLR-12051: Adding error log in case of data loss
This commit is contained in:
parent
78097d2098
commit
05d4a9320c
|
@ -347,6 +347,7 @@ final class ShardLeaderElectionContext extends ShardLeaderElectionContextBase {
|
||||||
|
|
||||||
Replica.Type replicaType;
|
Replica.Type replicaType;
|
||||||
String coreNodeName;
|
String coreNodeName;
|
||||||
|
boolean setTermToMax = false;
|
||||||
try (SolrCore core = cc.getCore(coreName)) {
|
try (SolrCore core = cc.getCore(coreName)) {
|
||||||
|
|
||||||
if (core == null) {
|
if (core == null) {
|
||||||
|
@ -365,9 +366,11 @@ final class ShardLeaderElectionContext extends ShardLeaderElectionContextBase {
|
||||||
ZkShardTerms zkShardTerms = zkController.getShardTerms(collection, shardId);
|
ZkShardTerms zkShardTerms = zkController.getShardTerms(collection, shardId);
|
||||||
if (zkShardTerms.registered(coreNodeName) && !zkShardTerms.canBecomeLeader(coreNodeName)) {
|
if (zkShardTerms.registered(coreNodeName) && !zkShardTerms.canBecomeLeader(coreNodeName)) {
|
||||||
if (!waitForEligibleBecomeLeaderAfterTimeout(zkShardTerms, coreNodeName, leaderVoteWait)) {
|
if (!waitForEligibleBecomeLeaderAfterTimeout(zkShardTerms, coreNodeName, leaderVoteWait)) {
|
||||||
log.info("Can't become leader, term of replica {} less than leader", coreNodeName);
|
|
||||||
rejoinLeaderElection(core);
|
rejoinLeaderElection(core);
|
||||||
return;
|
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
|
// 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);
|
zkController.getShardTerms(collection, shardId).setTermEqualsToLeader(coreNodeName);
|
||||||
}
|
}
|
||||||
super.runLeaderProcess(weAreReplacement, 0);
|
super.runLeaderProcess(weAreReplacement, 0);
|
||||||
|
|
Loading…
Reference in New Issue