PikaLabs / floyd

A raft consensus implementation that is simply and understandable
GNU General Public License v3.0
321 stars 106 forks source link

int FloydImpl::ReplyRequestVote里面有bug么? #37

Closed peacedog123 closed 6 years ago

peacedog123 commented 6 years ago

注释和论文里面有写: // if votedfor is null or candidateId, and candidated's log is at least as up-to-date // as receiver's log, grant vote

但是这个rpc实现逻辑里面,好像完全没有去判断FloydContext内部的vote_for_ip和vote_for_port, 事实是如果一个follower变成candidate后,首先会把vote_for_ip和vote_for_port设置成自己;此时如果收到RequestVoteRPC请求过来,应该直接return false, 表明自己这一轮已经投过票了(投给自己)

不知道我理解的对不对?谢谢

gaodq commented 6 years ago

在这里判断了 https://github.com/PikaLabs/floyd/blob/4113bef85e7fec2db743b7833c870574e106e239/floyd/src/floyd_impl.cc#L747-L753

peacedog123 commented 6 years ago

谢谢,pull了最新的代码后发现有了