You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// it is makesense hereifr.configurations.latestIndex==0 {
if!didWarn {
r.logger.Warn("no known peers, aborting election")
didWarn=true
}
}
// The code is: WHEN the configuration is committed AND current node is not a voter THEN abort election// Why handle this situation separately?// Why not merge this into the 'else' below?elseifr.configurations.latestIndex==r.configurations.committedIndex&&!hasVote(r.configurations.latest, r.localID) {
if!didWarn {
r.logger.Warn("not part of stable configuration, aborting election")
didWarn=true
}
} else {
metrics.IncrCounter([]string{"raft", "transition", "heartbeat_timeout"}, 1)
// The code is:// WHEN (configuration is uncommitted) AND current node is a voter THEN into candidate// WHEN (configuration is committed OR configuration is uncommitted) AND current node is not a voter THEN abort election.// // Why not implement this logic in this way and delete the "else if" block:// WHEN (configuration is committed OR configuration is uncommitted) AND current node is a voter THEN into candidate// WHEN (configuration is committed OR configuration is uncommitted) AND current node is not a voter THEN abort election.ifhasVote(r.configurations.latest, r.localID) {
r.logger.Warn("heartbeat timeout reached, starting election", "last-leader-addr", lastLeaderAddr, "last-leader-id", lastLeaderID)
r.setState(Candidate)
return
} elseif!didWarn {
r.logger.Warn("heartbeat timeout reached, not part of a stable configuration or a non-voter, not triggering a leader election")
didWarn=true
}
}
The text was updated successfully, but these errors were encountered:
code here:
raft/raft.go
Line 242 in 8f99c15
see the comment please.
The text was updated successfully, but these errors were encountered: