JacksonYao287 commented on pull request #500:
URL: https://github.com/apache/ratis/pull/500#issuecomment-922250260


   thanks @kaijchen for the review!
   
   > To avoid unnecessary step down, PreVote should be used.
   
   PreVote is very import and has been supported by RATIS, but for some 
uncertain reason , we disable it in some components of ozone(for example, scm)
   
   ```
   RatisUtil.java
    /**
      * Set properties related to Raft leader election.
      *
      * @param properties RaftProperties instance which will be updated
      *
      */
     private static void setRaftLeadElectionProperties(
         final RaftProperties properties) {
       // Disable the pre vote feature (related to leader election) in Ratis
       RaftServerConfigKeys.LeaderElection.setPreVote(properties, false);
     }
   ```
   
   
   > > i think if candidate has a higher term, 
`ServerState.compareLog(lastEntry, candidateLastEntry)` will definitely return 
-1, so that decideVote(..) will return true!
   > 
   > This is not true. The candidate has a higher term doesn't mean it has 
higher lastEntryTerm.
   > 
   
   the below is extracted from raft paper(5.4.1 Election restriction)
   
   Raft uses the voting process to prevent a candidate from winning an election 
unless its log contains all committed entries. A candidate must contact a 
majority of the cluster in order to be elected, which means that every 
committed entry must be present in at least one of those servers. If the 
candidate’s log is at least as up-to-date as any other log in that majority 
(where “up-to-date” is defined precisely below), then it will hold all the 
committed entries. The RequestVote RPC implements this restriction: the RPC 
includes information about the candidate’s log, and the voter denies its vote 
if its own log is more up-to-date than that of the candidate.
   
   Raft determines which of two logs is more up-to-date by comparing the index 
and term of the last entries in the logs. If the logs have last entries with 
different terms, then the log with the later term is more up-to-date. If the 
logs end with the same term, then whichever log is longer is more up-to-date.
   
   so, here, the key point is what `up-to-date` stands for? according to the 
paper, a log with a higher term in its last entry is more up-to-date than a log 
with a lower term in its last entry. it means even if a log has a smaller 
index, it can also be more up-to-date than a log with a bigger index. that 
means a log with a shorter length can be much more up-to-date than a log with a 
longer length.   {index = 1, term = 100} is more up-to-date than {index = 100, 
term = 1}.
   
   
   


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to