[
https://issues.apache.org/jira/browse/RATIS-998?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17153211#comment-17153211
]
Glen Geng edited comment on RATIS-998 at 7/8/20, 3:40 AM:
----------------------------------------------------------
Together with
[RATIS-981]([https://issues.apache.org/jira/projects/RATIS/issues/RATIS-981?filter=allissues)|https://issues.apache.org/jira/projects/RATIS/issues/RATIS-981?filter=allissues]
stale leader will step down by itself.
was (Author: glengeng):
Together with
[RATIS-981]([https://issues.apache.org/jira/projects/RATIS/issues/RATIS-981?filter=allissues],]
stale leader will step down by itself.
> shouldWithholdVotes() should be triggered for handling higher term
> ------------------------------------------------------------------
>
> Key: RATIS-998
> URL: https://issues.apache.org/jira/browse/RATIS-998
> Project: Ratis
> Issue Type: Bug
> Components: server
> Affects Versions: 0.5.0
> Reporter: Glen Geng
> Assignee: Glen Geng
> Priority: Major
>
>
> shouldWithholdVotes() should be triggered for handling higher term
>
> Current code is
> {code:java}
> private boolean shouldWithholdVotes(long candidateTerm) {
> if (state.getCurrentTerm() < candidateTerm) {
> return false;
> } else if (isLeader()) {
> return true;
> } else {
> // following a leader and not yet timeout
> return isFollower() && state.hasLeader() &&
> role.getFollowerState().map(FollowerState::shouldWithholdVotes).orElse(false);
> }
> }
> {code}
> Modify to
> {code:java}
> private boolean shouldWithholdVotes(long candidateTerm) {
> if (state.getCurrentTerm() >= candidateTerm) {
> return false;
> } else if (isLeader()) {
> return true;
> } else {
> // following a leader and not yet timeout
> return isFollower() && state.hasLeader() &&
> role.getFollowerState().map(FollowerState::shouldWithholdVotes).orElse(false);
> }
> }
> {code}
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)