Tencent / paxosstore

PaxosStore has been deployed in WeChat production for more than two years, providing storage services for the core businesses of WeChat backend. Now PaxosStore is running on thousands of machines, and is able to afford billions of peak TPS.
Other
1.67k stars 336 forks source link

关于一致性读的疑问 #23

Open htner opened 5 years ago

htner commented 5 years ago
简单的说, 读接口即读当前的plog, 并判定是否是最新数据(分布式角度). 更具体的说: 
-  读接口LocalChosenIndex + 1 == OtherMaxIndex  当且仅当OtherMaxIndex均
    为Pending时, 本地chosen数据最新

这里我有一个疑问, OtherMaxIndex均能确定处于Pending时,是否是即使处于这么一个中间状态:paxos acceptors已经形成多数派但是设置的proposer并没有到达chosen,就当作这种状态还没有真的chosen.

另外源码中,

int can_read_3svr(..) {
 ...
 if (is_peer_chosen(peer_status)) {               
        return PAXOS_GET_LOCAL_OUT; 
 }
return PAXOS_GET_MAY_LOCAL_OUT;
}

跟note文档描述并不是一致的。在远端都不是chosen的情况,选择了重做写并等待或返回失败。

我的第二个疑问是, 源码是不是选择了更严格的模式,因为存在上面说的中间的状态的情况,选择了重做完等待或者返回失败

dengoswei commented 5 years ago

短回答:

  1. chosen是为实现上方便引入的额外状态, 非paxos原生;
  2. 这个case下: 开源代码 != 内部代码;

长回答: 问题1: 这里定义

问题2: != 实际代码的原因;

  1. 实际代码对3机的情况做了状态枚举, 某些状态条件下可推导出本机数据最新, 可降低线上读失败率;
  2. 实际代码未放在paxoskv库下, 腾挪开源时候简化了下;