You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2020/05/30 07:16:39 UTC

[GitHub] [rocketmq] zhangyixin1222 removed a comment on issue #2056: 关于目前raft协议选举中存在的问题及改进策略

zhangyixin1222 removed a comment on issue #2056:
URL: https://github.com/apache/rocketmq/issues/2056#issuecomment-636270759


   > > raft协议在网络抖动,机器临时故障等极小概率情况下会产生以下选举问题:
   > > 假定有编号为【1,2,3,4,5,6,7】共7个结点构成了一个选举整体,当结点1作为候选人发起term=6的投票,该term对应投票为【1,2,3,4】所接受,结点1作为leader执行leader职责前,刚好结点7发起term=7的投票(因为网络抖动原因结点7发起的term=6刚好未被结点【1,2,3,4】所接收),抛开上帝视角具体分析,此时存在以下两种情况:
   > > 情况1:结点【4,5,6,7】多数结点接受结点7该term=7的选举,结点7作为leader执行职责,该情况下目前所用raft协议能保证结点1会自动失去leader资格。
   > > 情况2:结点【5,6,7】等少数结点接受结点7该term=7的选举,结点7未作为leader执行职责,但此时因为【5,6,7】结点已经认可了term=7的任期,会导致结点1以term=6所发送提议无法被接受,但结点1因为已经此实确实获取多数结点认可,在提议被多数接受后会进行提交。可惜目前所用的raft协议未考虑该情况下的处理方案。
   > > 解决策略:1、引入结点在接受到leader名义发起的提议后,如果term<自身已知选举认可term且term>自身已提交term时,对提议仅进行记录但拒绝接受该提议。当接受到提交请求时,如果提交所用term>自身已提交term,则找到对应提议并无条件进行提交(因为raft协议的提议提交命令发送前提为大多数已经接受了)。2、如果接受了提议,则在自身未主动探测到leader丢失下,拒绝对后续的选举term进行投票(以保证在接受结点1提议后结点7无法获取到多数结点的认可当选为leader出现双主问题).
   > > 问题扩展:实际情况会存在网络抖动引起的N个(N>=2)结点同时误认自己是leader或当前leader因为所用term并非全局视角下的最大term在履行leader职责时未受少数结点认可存在的问题
   > 
   > In my opinion, the situation that you describe before is inevitable. PRE-VOTE request can minimize the probability of leadership transition. Candidate send PRE-VOTE request before send the true VOTE request. If PRE-VOTE failed(do not receive majority's vote), candidate reset vote timeout to wait for the next PRE-VOTE. If PRE-VOTE successed(receive majority's vote), candidate will send VOTE request.
   > Openmessaging-dledger has already support PRE-VOTE protocol, it maybe help you. Code address is [https://github.com/openmessaging/openmessaging-storage-dledger](url)
   > The PRE-VOTE mechanism details please refer to RAFT paper.
   prevote只能保证参与选举时的结点拥有了最新的日志信息,当结点1跟结点7都具有最新信息,并在prevote阶段因此都获取了候选人资格,在获取了候选人资格后一段时间内因为网络等问题发生一定时间段的间歇性脑裂,导致了term变更期间因随机等待时常差异造成同一时刻会用不同term参与选举在特殊情况下产生了之前描述的问题


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org