PikaLabs/floyd

int FloydImpl::ReplyRequestVote里面有bug么?

peacedog123 opened this issue · 2 comments

注释和论文里面有写:
// 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

在这里判断了

if (!context_->voted_for_ip.empty() || context_->voted_for_port != 0) {
LOGV(INFO_LEVEL, info_log_, "FloydImpl::ReplyRequestVote: I %s:%d have voted for %s:%d in this term %lu",
options_.local_ip.c_str(), options_.local_port, context_->voted_for_ip.c_str(),
context_->voted_for_port, request_vote.term());
BuildRequestVoteResponse(context_->current_term, granted, response);
return -1;
}

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