RequestVote RPC confusion about arguments

70 views
Skip to first unread message

Daniel Gleason

unread,
Feb 28, 2023, 10:58:42 PM2/28/23
to raft-dev
I don't understand this last sentence.  If "votedFor" is null, or candidateId && candidates log is at least as up to date as receives log, grant vote. Does this mean we would need the candidate to also send over its log in the RPC? Why is this excluded from the arguments list? Shouldn't we also include the log from the sender?


Oren Eini (Ayende Rahien)

unread,
Mar 1, 2023, 1:59:41 AM3/1/23
to raft...@googlegroups.com
You need to send the last (index, term) for the candidate, yes.

On Wed, Mar 1, 2023 at 5:58 AM Daniel Gleason <damia...@gmail.com> wrote:
I don't understand this last sentence.  If "votedFor" is null, or candidateId && candidates log is at least as up to date as receives log, grant vote. Does this mean we would need the candidate to also send over its log in the RPC? Why is this excluded from the arguments list? Shouldn't we also include the log from the sender?


--
You received this message because you are subscribed to the Google Groups "raft-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to raft-dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/raft-dev/265e2f8b-29cc-460f-b1b7-223ec7f823c5n%40googlegroups.com.


--
Oren Eini
CEO   /   Hibernating Rhinos LTD
Skype:  ayenderahien
Support:  sup...@ravendb.net
  

Daniel Gleason

unread,
Mar 1, 2023, 11:22:06 AM3/1/23
to raft-dev
Oh and then you would use that to compare the last index of the receivers `log[index]` and see if the term is the same? Is there an example of how these RPCs are laid out in python or some other language?

Daniel Gleason

unread,
Mar 1, 2023, 11:26:41 AM3/1/23
to raft-dev
The way I imagine this looking is something like this:


class LogEntry:
    term: int
    command: Command


log: list[LogEntry] = []

class RequestVote:
    term: int
    candidateId: str
    lastLogIndex: int
    lastLogTerm: int


def on_request_vote_recieved(vote: RequestVote) -> None:
    if not votedFor:
        send(success)
    elif log[vote.lastLogIndex].term >= lastLogTerm:
       send(success)
    else
         send_failure()



Am I missing something here?


On Tuesday, February 28, 2023 at 10:59:41 PM UTC-8 aye...@ayende.com wrote:
Reply all
Reply to author
Forward
0 new messages