tikv / raft-rs

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

Introduce enum priority #493

Closed Connor1996 closed 1 year ago

Connor1996 commented 1 year ago

Signed-off-by: Connor1996 zbk602423539@gmail.com

u64 based priority is not handy, when you want to lower or raise the priority of one peer, you have to adjust all the peers'.

Connor1996 commented 1 year ago

Test would be fixed later if the change is acceptable.

BusyJay commented 1 year ago

This is a breaking change and if users have adjusted the priority, this can lead to expected behavior during rolling update.

Connor1996 commented 1 year ago

This is a breaking change and if users have adjusted the priority, this can lead to expected behavior during rolling update.

Yes, but we can't find a way to not break that. And seems priority isn't widely used and the interface is breaking which user should be aware of that and handle it in upper level.

Connor1996 commented 1 year ago

Do you have any better idea? If the priority field in kvproto is i64, everything would work fine, but it's also breaking

BusyJay commented 1 year ago

You can change the priority in Config to i64 and add a new priority field defined as s64 to pb definition. If new field is not set, then use the old field; otherwise use the new field. When broadcasting request vote, both fields are set if the priority is larger than 0.

This change is not a fully compatible change, but it makes minimal impact that only new priority is not recognized by the old nodes.