Skip to content

Follower rejecting leader's pre-vote #606

@k-jingyang

Description

@k-jingyang

Hello, thanks for the library! We were trying out raft v1.7.0, and found that the pre-vote implementation has a bug where a follower rejects the pre-vote req from node X even when when the follower thinks that X is the leader.

This is the offending line. https://github.com/hashicorp/raft/blob/main/raft.go#L1752

// Check if we have an existing leader [who's not the candidate] and also
var candidate ServerAddress // ISSUE: this is not set at all
candidateID := ServerID(req.ID)

// if the Servers list is empty that mean the cluster is very likely trying to bootstrap,
// Grant the vote
if len(r.configurations.latest.Servers) > 0 && !inConfiguration(r.configurations.latest, candidateID) {
	r.logger.Warn("rejecting pre-vote request since node is not in configuration",
		"from", candidate)
	return
}

if leaderAddr, leaderID := r.LeaderWithID(); leaderAddr != "" && leaderAddr != candidate { // ISSUE: so this will always return true as long as the follower has a leader
	r.logger.Warn("rejecting pre-vote request since we have a leader",
		"from", candidate,
		"leader", leaderAddr,
		"leader-id", string(leaderID))
	return
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions