Tencent / phxpaxos

The Paxos library implemented in C++ that has been used in the WeChat production environment.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] Instance :: OnTimeout 中没有处理AskforcheckpointMode

zqdai opened this issue · comments

如题。在AskforcheckpointMode模式下,Instance::OnReceive会忽略所有的paxos消息,然而OnTimeout却没有忽略。在如下事件发生时会导致问题:
1、一个节点N正常启动,instance处于非常落后的状态,设其当前instance id为x。
2、N收到一个新的propose请求并进行了处理(prepare+accept)。
3、N通过AskforLearn发现自己落后,并开始传输chekcpoint。
4、在checkpoint传输过程中,prepare超时,通过OnTimeout进行了第二次prepare+accept。此时,paxos存储中应该是完全空的,但由于该问题被意外写入了一个记录。
5、checkpoint传输完成。N重启。
6、重启后成功加载checkpoint。
7、paxos初始化,发现当前日志里最大的instance id是x,而checkpoint的instance id远大于x,触发保护逻辑,paxos初始化失败。

commented

是bug,感谢 @zqdai ,应该在Instance :: OnReceivePaxosMsg函数进行消息忽略,即可杜绝所有源头。还好这个bug能碰撞到的概率非常低。