baidu / braft

An industrial-grade C++ implementation of RAFT consensus algorithm based on brpc, widely used inside Baidu to build highly-available distributed systems.
Apache License 2.0
3.84k stars 862 forks source link

_leader_lease should also be considered when handling vote #463

Open BusyJay opened 5 days ago

BusyJay commented 5 days ago

Currently only _follower_lease is considered, and leader will never update _follower_lease, so _follower_lease will always expire on leader side. If a follower starts election in an idle group, leader will vote for follower even the leader lease is still valid. Leader will call step_down to invalidate _leader_lease before vote, so there seems to be no correctness problem. But if a follower is isolated for a while and then return, it's likely to cause leadership change and lead to latency jitter on the client side.