-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
raft: introduce persistent leader term in raft log #122446
Comments
cc @cockroachdb/replication |
We are also planning to persist When we do so, we should be sure to not create confusion by also introducing a field called |
Naming-wise, I think we would be good with something like |
@nvanbenschoten The |
do we need the leader term in Soft and Hard state? |
Yes, that is correct. |
The raft log currently does not "remember" the last term of the leader who appended entries to the log. The state of a raft instance currently contains the
Term
of its latest vote, which might or might not be the leader. This means that the content of the log is not necessarily a prefix of thisTerm
's leader.The impact of this manifests in multiple ways:
MsgApp
message, or has to cap it at the follower'sMatch
index.We should introduce a "leader term" field into the state (both the
HardState
and the in-memory state of the raft log), with the following invariant:The
LeaderTerm
should be updated every time the log accepts an append from a leader. The "leader term" can be used for safety checks on the follower, before advancing the commit index. It can also be used for a simpler async log protocol.Ultimately, the
LeaderTerm
is the missing piece of state that makes Raft log equivalent to Paxos acceptor (TODO: link to the doc). The equivalence is that theLeaderTerm
of the log is the "max accepted proposal ID" in Paxos.The introduction of
LeaderTerm
can be done as:LeaderTerm = Log.Entry[last].Term
.Jira issue: CRDB-37894
Epic CRDB-39898
The text was updated successfully, but these errors were encountered: