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.95k stars 880 forks source link

leader can still accept read requests when transferring leader #468

Open BusyJay opened 2 months ago

BusyJay commented 2 months ago

Because new leader has to disrupt the old leader before it can receive votes from other candidates, so old leader will always has the latest data before it votes for the new leader and in lease. So it's safe for old leader to accept read requests. Though it should not accept write requests to avoid breaking transfer leader.

The current implementation will call _leader_lease.on_leader_stop(), which will expires lease and prevent accepting any read requests.