dcernahoschi
dcernahoschi

Reputation: 15240

Apache Curator lock and happens before

Assume I'm a zookeeper client that create/update/delete some zookeeper (persistent) node while holding the lock (InterProcessMutex). Is it guaranteed that another client that gets the same lock after I released it will see my modifications?

I assume the answer is yes, as lock release happens after node updates on each zookeeper server, but anyone can confirm this assumption?

Upvotes: 1

Views: 161

Answers (1)

Randgalt
Randgalt

Reputation: 2956

Let's walk through this and see (using client A and B):

  1. A and B contend for the lock and A acquires it
  2. B now has an outstanding watch on the lock
  3. A modifies some ZNodes
  4. A releases the lock (which means deleting his lock ZNode)
  5. B's lock watcher (managed by Curator) gets notified

At step 5 B is guaranteed to see all modifications that happened prior to A's lock node getting deleted as ZooKeeper guarantees message ordering. So, the answer to your question is Yes.

Upvotes: 2

Related Questions