tikv / raft-rs

Raft distributed consensus algorithm implemented in Rust.
Apache License 2.0
2.93k stars 394 forks source link

How to handle committed ConfChangeV2 #446

Open haraldng opened 3 years ago

haraldng commented 3 years ago

Is it possible to provide an example on how to handle a committed ConfChangeV2 Entry? The example in single_mem_node is still a TODO and in five_mem_node still uses the old ConfChange.

Thanks in advance

BusyJay commented 3 years ago

It depends on how would you like to exit joint state. If auto_leave is configured, then raft node should propose a leave joint command when enter join is applied, which is informed by apply_conf_change. All you need to do is maintaining the metadata according the the committed entries.

If auto_leave is set to false, then you need to propose a leave joint command, which is just an empty conf change, manually.

I hope tests code can help for now example is missing:

https://github.com/tikv/raft-rs/blob/7c21f8d12f2043c43004fca48861568db7c76bd9/harness/tests/integration_cases/test_raw_node.rs#L176-L462

haraldng commented 3 years ago

I don't understand how to auto leave the joint state. What metadata need to be maintained after performing apply_conf_change and what actions need to be performed?