runzhiwang opened a new pull request #378:
URL: https://github.com/apache/incubator-ratis/pull/378
## What changes were proposed in this pull request?
**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.
**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.
```
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) {
...
}
```
**How to fix ?**
After leader `final boolean termUpdated = changeToFollower(candidateTerm,
true, "recognizeCandidate:" + candidateId);`, when can get fs again.
## What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/RATIS-1268
## How was this patch tested?
no need to add new ut.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]