-
Notifications
You must be signed in to change notification settings - Fork 408
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
How does learner become follower? #457
Comments
Raft-rs tracks the status in configuration. It's complicated whether a peer is learner or not when considering joint state. I suggest application also keep tracking the confstate.
It depends on what do you want. If you just want to see if it's safe to promote a learner to voter, you can check the implementation in TiKV, I think it's the most suitable way without depending on much details of raft-rs.
Either way is OK. It depends on how much you want to control the process. TiKV choose to use ConfChangeV2 to promote a learner and demote a voter at the same time with transition set to explicit. You may want to check out https://github.com/tikv/rfcs/blob/master/text/0054-joint-consensus.md to see how TiKV adapts joint consensus.
I'm afraid no. Learner is a standalone role that can performs without becoming a voter. So raft-rs will not promote it automatically. For example, TiDB uses voters and learners at the same time to achieve isolated HTAP with strong consistency. |
@BusyJay, thanks for the reply!
So for safety:
|
If the commit index become smaller than the leader's truncated index after applying the configuration change, then leader will have to send snapshot to at lease one node to make quorum catch up enough logs. Snapshot is slow and it will pause the whole group. Checking leader's commit index is a stricter constraint, which may not be possible in all conditions. For example, a fast voter may never be removed with such requirement.
It's for group commit, which is an extension, you can safely ignore it generally.
What if leader does nothing and fails? It's not the problem that multiple nodes are being promoted but the fact that there is only one healthy node in the group. We consider singleton is dangerous, we want to add multiple replicas as soon as possible. The comment is not accurate though. |
I think I have almost everything needed. Edit: Is it the index of latest entry in the latest snapshot? (Therefore, we do not need to send a snapshot after this condition is met) |
It's the minimal index of available logs minus one. |
@BusyJay, appreciate for help. |
From my tests there is no automatic transmission from learner state to follower in v0.6. How to make it right then? I suppose it could be done before ticking the leader's raft.
Does Raft-rs track the learners status or should I do it by using ConfState after
apply_conf_change
? Etcd's ProgressTracker has fieldIsLearner bool
.Is it enough for the leader to check ProgressTracker of the learners to ensure they match his commited_index
(learner's progress.committed_index == leader's raft.raft_log.committed && learner's ProgressState != Snapshot)
?Or maybe a learner's
state == ProgressState::Replicate
is sufficient?Should the leader propose new configuration with exactly one node transmitted from learner to follower at a time or one ConfChangeV2 with all the learner ids and
transition = Implicit
will do the thing?Is it possible that in the future this transition will be made by raft-rs?
The text was updated successfully, but these errors were encountered: