Skip to content

The parameter Should be C_old configuration in runFollower()? #635

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
zivfuture opened this issue Feb 20, 2025 · 0 comments
Open

The parameter Should be C_old configuration in runFollower()? #635

zivfuture opened this issue Feb 20, 2025 · 0 comments

Comments

@zivfuture
Copy link

code here:

raft/raft.go

Line 242 in 8f99c15

if hasVote(r.configurations.latest, r.localID) {

see the comment please.

// it is makesense here
if r.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?
else if r.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.
	if hasVote(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
	} else if !didWarn {
		r.logger.Warn("heartbeat timeout reached, not part of a stable configuration or a non-voter, not triggering a leader election")
		didWarn = true
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant