Zookeeper Watches 系统是否存在错误,或者这是 CAP 定理的限制?

Does the Zookeeper Watches system have a bug, or is this a limitation of the CAP theorem?

动物园管理员在看documentation states

"A client will see a watch event for a znode it is watching before seeing the new data that corresponds to that znode." Furthermore, "Because watches are one time triggers and there is latency between getting the event and sending a new request to get a watch you cannot reliably see every change that happens to a node in ZooKeeper."

重点是,不能保证您会收到手表通知。

这很重要,因为在像 Clojure 的 Avout, you're trying to mimic Clojure's Software Transactional Memory, over the network using Zookeeper 这样的系统中。这依赖于每次更改都有一个监视通知。

现在我正在尝试确定这是一个编码缺陷,还是一个基本的计算机科学问题(即 CAP Theorem)。

我的问题是:Zookeeper Watches 系统是否存在错误,或者这是 CAP 定理的限制?

这似乎是 ZooKeeper 实现 watch 的方式的限制,而不是 CAP 定理的限制。有一个向 ZooKeeper 添加连续监视的开放功能请求:https://issues.apache.org/jira/browse/ZOOKEEPER-1416

etcd 有一个使用长轮询的 watch 函数。您需要考虑的限制是在收到第一个长轮询结果和重新轮询之间可能会发生多个事件。这大致类似于 ZooKeeper 的问题。但是他们有一个解决方案:

However, the watch command can do more than this. Using the index [passing the last index we've seen], we can watch for commands that have happened in the past. This is useful for ensuring you don't miss events between watch commands.

curl -L 'http://127.0.0.1:4001/v2/keys/foo?wait=true&waitIndex=7'