[ 
https://issues.apache.org/jira/browse/RATIS-1001?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Glen Geng updated RATIS-1001:
-----------------------------
    Description: 
 

During SCM-HA, SCM not only needs to know if it is a leader, but also needs to 
know which term it is in charge of.

 

Assume such a case: underlying raft node was leader on term 1, then step down 
as follower on term 2, then init election and become leader again on term 3. If 
term is not exposed with leader information, SCM can not distinguish that it is 
a leader of term 1 or that of term 3.

 

  was:
 

I assume that {{shouldWithholdVotes()}} is used to handle request vote request 
with higher candidate term from disruptive server, but currently it just 
ignored such requests, since it only take effect when {{(state.getCurrentTerm() 
>= candidateTerm)}} .

shouldWithholdVotes() should be triggered for handling higher term. If 
currentTerm is larger or equal to candidateTerm, just reject the request vote, 
no need further handling.

 

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}
 


> CLONE - shouldWithholdVotes() should be triggered for handling higher term
> --------------------------------------------------------------------------
>
>                 Key: RATIS-1001
>                 URL: https://issues.apache.org/jira/browse/RATIS-1001
>             Project: Ratis
>          Issue Type: Improvement
>          Components: server
>            Reporter: Glen Geng
>            Assignee: Glen Geng
>            Priority: Major
>
>  
> During SCM-HA, SCM not only needs to know if it is a leader, but also needs 
> to know which term it is in charge of.
>  
> Assume such a case: underlying raft node was leader on term 1, then step down 
> as follower on term 2, then init election and become leader again on term 3. 
> If term is not exposed with leader information, SCM can not distinguish that 
> it is a leader of term 1 or that of term 3.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to