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 881 forks source link

fix #314

Open dragonylffly opened 3 years ago

dragonylffly commented 3 years ago

@PFZheng

dragonylffly commented 3 years ago

@chenzhangyi As the codes as well as comments in Lines 86-88 ballot_box.cpp, the elements before last_committed_index are removed. So it just needs to find the largest last_committed_index, use reverse search to avoid calling bl.granted() and updating last_committed_index multiple times