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.99k stars 886 forks source link

关于ELEADERCONFLICT的错误情况,一个给定的Term,会出现两个以上的Leader? #285

Closed ehds closed 3 years ago

ehds commented 3 years ago

https://github.com/baidu/braft/blob/d1f13bd34504724ed03d7ba4991969ff78c77542/src/braft/node.cpp#L2366 https://github.com/baidu/braft/blob/d1f13bd34504724ed03d7ba4991969ff78c77542/src/braft/node.cpp#L2572

以上两个地方会出现ELEADERCONFLICT错误,也就是给定的 term,会有超过一个数目的Leader。 但是从Raft协议来说,在一个 term 内,只会存在一个 Leader。

Election Safety:at most one leader can be elected in a given term.§5.2

想知道在 braft 中什么情况下会存在 leader 冲突的情况。

Edward-xk commented 3 years ago

实际上不会出现。这两处是一个异常保护措施。