RAFT中的COMMIT
先上结论:
Commit这个概念不仅仅需要考虑被大多数节点说接受,同时也需要考虑是否在当前任期,Leader只能Commit当前任期内的内容。
1. commit意味着什么
看下原文中的两处介绍。
An entry is considered committed if it is safe for that entry to be applied to state machines.
当日志安全被应用在状态机中时,则其为Commited。
The leader decides when it is safe to apply a log entry to the state machines; such an entry is called committed.
Leader决定将log应用到状态机的时间,应用的log则为Commited.
2. 需要明确的概念
Commit是如何进行维护的呢?
-
首先是Leader确定大多数节点已经将日志复制到本地,随后Leader更新LeadCommit参数。
-
接着各Server接受到新的心跳,收到Leader的信息,更新本地CommitIndex。
-
投票选举的过程
· 每一个Server会维持一个LastLogIndex和LastLogTerm,作为与其他节点交流时,进行新旧比较的依据。
· 当Candidate发送给Follower RequestVote RPC请求后,