Skip to content

Handle RequestVote correctly if the Candidate has stale log #10

@jkozlowski

Description

@jkozlowski

This is following #9 code review. Similarly to what we do in the follower, leaders and candidates should check if the node requesting a vote has the log at least as up-to-date as ours, otherwise we should not grant the vote.

Receiver implementation (for RequestVote):

  1. Reply false if term < currentTerm (§5.1)
  2. If votedFor is null or candidateId, and candidate's log is at
    least as up-to-date as receiver’s log, grant vote (§5.2, §5.4)

Additionally, looking at go code, RequestVote handling is exactly the same for all node types, so maybe it would be good to refactor that bit of state somehow, so that we can have a generic function for handling it?

I wouldn't mind taking a stab at this over the next week, just need a bit of time to setup a new machine a just bought...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions