dev-urandom / graft

Guys have you heard of this consensus protocol called raft?
12 stars 6 forks source link

ReceiveRequestVote incorrectly setting term and stepping down. #7

Closed benmills closed 11 years ago

benmills commented 11 years ago

If a server receives a RequestVoteMessage with a log that is more up-to-date than the candidate's log should it really set the term to the voter's term and step down?

wjdix commented 11 years ago

Based on my reading of this (particularly step 2) screen shot 2013-08-25 at 2 27 23 pm

that is the correct behavior.

benmills commented 11 years ago

That's not exactly the scenario I'm thinking of. Imagine the candidate has term 1 and last index of 0 (ignoring the log term for simplicity). The voter has term 0 and a last index of 1. The code as it stands today will cause the candidate to step down and set it's term to the message's term which is 0. I think it should just continue the election and mark that as a lost vote.

On Sunday, August 25, 2013, wjdix wrote:

Based on my reading of this (particularly step 2) [image: screen shot 2013-08-25 at 2 27 23 pm]https://f.cloud.github.com/assets/39646/1022935/681c9866-0dbc-11e3-9f93-e634cbfafc54.png

that is the correct behavior.

— Reply to this email directly or view it on GitHubhttps://github.com/dev-urandom/graft/issues/7#issuecomment-23233831 .

wjdix commented 11 years ago

Got it. I think candidates are stepping down even if the condition in step 1 holds. You're right; I'll see if I can fix it today.

benmills commented 11 years ago

I'm pretty sure I introduced this code so I'm happy to fix it, just wanted to make sure I was thinking about it right. I also think the scenario that makes this an issue might be either impossible or require a pretty complex set of partitions.

On Monday, August 26, 2013, wjdix wrote:

Got it. I think candidates are stepping down even if the condition in step 1 holds. You're right; I'll see if I can fix it today.

— Reply to this email directly or view it on GitHubhttps://github.com/dev-urandom/graft/issues/7#issuecomment-23261598 .