[
https://issues.apache.org/jira/browse/RATIS-1268?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
runzhiwang updated RATIS-1268:
------------------------------
Description:
What's the problem ?
For example, when s0 is leader, and s1 askForVote, in the first rpc of
askForVote, s0 can not vote for s1, even though s1's log catch up. When s1
askForVote the second time, s0 has become follower in the first askForVote, so
s0 can vote for s1, waste one rpc call.
What's the reason ?
As the following code shows, when s0 is leader,
role.getFollowerState().orElse(null) should return null,
then can not pass check if (fs != null && candidate != null) because fs is
null, so s0 can not vote for s1.
{code:java}
FollowerState fs = role.getFollowerState().orElse(null);
if (shouldWithholdVotes(candidateTerm)) {
...
} else if (state.recognizeCandidate(candidateId, candidateTerm)) {
final boolean termUpdated = changeToFollower(candidateTerm, true,
"recognizeCandidate:" + candidateId);
RaftPeer candidate = getRaftConf().getPeer(candidateId);
if (fs != null && candidate != null) {
...
}
{code}
How to fix ?
After leader final boolean termUpdated = changeToFollower(candidateTerm, true,
"recognizeCandidate:" + candidateId);, we can get fs again.
> Fix leader can not vote for candidate
> -------------------------------------
>
> Key: RATIS-1268
> URL: https://issues.apache.org/jira/browse/RATIS-1268
> Project: Ratis
> Issue Type: Bug
> Reporter: runzhiwang
> Assignee: runzhiwang
> Priority: Major
> Time Spent: 20m
> Remaining Estimate: 0h
>
> What's the problem ?
> For example, when s0 is leader, and s1 askForVote, in the first rpc of
> askForVote, s0 can not vote for s1, even though s1's log catch up. When s1
> askForVote the second time, s0 has become follower in the first askForVote,
> so s0 can vote for s1, waste one rpc call.
> What's the reason ?
> As the following code shows, when s0 is leader,
> role.getFollowerState().orElse(null) should return null,
> then can not pass check if (fs != null && candidate != null) because fs is
> null, so s0 can not vote for s1.
> {code:java}
> FollowerState fs = role.getFollowerState().orElse(null);
> if (shouldWithholdVotes(candidateTerm)) {
> ...
> } else if (state.recognizeCandidate(candidateId, candidateTerm)) {
> final boolean termUpdated = changeToFollower(candidateTerm, true,
> "recognizeCandidate:" + candidateId);
> RaftPeer candidate = getRaftConf().getPeer(candidateId);
> if (fs != null && candidate != null) {
> ...
> }
> {code}
> How to fix ?
> After leader final boolean termUpdated = changeToFollower(candidateTerm,
> true, "recognizeCandidate:" + candidateId);, we can get fs again.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)