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

380 views Asked by At

The Zookeeper Watches 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."

The point is, there is no guarantee you'll get a watch notification.

This is important, because in a sytem like Clojure's Avout, you're trying to mimic Clojure's Software Transactional Memory, over the network using Zookeeper. This relies on there being a watch notification for every change.

Now I'm trying to work out if this is a coding flaw, or a fundamental computer science problem, (ie the CAP Theorem).

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

1

There are 1 answers

0
Daniel Compton On BEST ANSWER

This seems to be a limitation in the way ZooKeeper implements watches, not a limitation of the CAP theorem. There is an open feature request to add continuous watch to ZooKeeper: https://issues.apache.org/jira/browse/ZOOKEEPER-1416.

etcd has a watch function that uses long polling. The limitation here which you need to account for is that multiple events may happen between receiving the first long poll result, and re-polling. This is roughly analogous to the issue with ZooKeeper. However they have a solution:

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'