Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CAP & BASE 页面对zookeeper read 一致性的论述错误 #1906

Closed
qqu0127 opened this issue Jan 28, 2023 · 1 comment
Closed

CAP & BASE 页面对zookeeper read 一致性的论述错误 #1906

qqu0127 opened this issue Jan 28, 2023 · 1 comment
Labels
bug Content error

Comments

@qqu0127
Copy link

qqu0127 commented Jan 28, 2023

https://javaguide.cn/distributed-system/theorem&algorithm&protocol/cap&base-theorem.html#cap-%E5%AE%9E%E9%99%85%E5%BA%94%E7%94%A8%E6%A1%88%E4%BE%8B
任何时刻对 ZooKeeper 的读请求都能得到一致性的结果是错误的,这应该是一个很常见的误区,由于read 并不会触发quorum内的sync,在同一时间点不同的client views 会因为网络延迟等原因呈现不同的结果

参照 https://zookeeper.apache.org/doc/current/zookeeperInternals.html#sc_consistency
Read operations in ZooKeeper are not linearizable since they can return potentially stale data.

@Snailclimb
Copy link
Owner

任何时刻对 ZooKeeper 的读请求都能得到一致性的结果是错误的,这应该是一个很常见的误区,由于read 并不会触发quorum内的sync,在同一时间点不同的client views 会因为网络延迟等原因呈现不同的结果

感谢已修正:

ZooKeeper 通过可线性化(Linearizable)写入、全局 FIFO 顺序访问等机制来保障数据一致性。多节点部署的情况下, ZooKeeper 集群处于 Quorum 模式。Quorum 模式下的 ZooKeeper 集群, 是一组 ZooKeeper 服务器节点组成的集合,其中大多数节点必须同意任何变更才能被视为有效。

由于 Quorum 模式下的读请求不会触发各个 ZooKeeper 节点之间的数据同步,因此在某些情况下还是可能会存在读取到旧数据的情况,导致不同的客户端视图上看到的结果不同,这可能是由于网络延迟、丢包、重传等原因造成的。ZooKeeper 为了解决这个问题,提供了 Watcher 机制和版本号机制来帮助客户端检测数据的变化和版本号的变更,以保证数据的一致性。

@Snailclimb Snailclimb added the bug Content error label Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Content error
Projects
None yet
Development

No branches or pull requests

2 participants