python-zk / kazoo

Kazoo is a high-level Python library that makes it easier to use Apache Zookeeper.
https://kazoo.readthedocs.io
Apache License 2.0
1.3k stars 387 forks source link

fix (recipe): don't set creation watch on lock predecessor node #490

Closed packysauce closed 6 years ago

packysauce commented 6 years ago

Using exists will register a creation, as well as update and deletion watch on the given node. This introduces a race, where the predecessor node can get deleted between the call to getChildren() and exists(). If that happens, the exists() sets a create watch on a node that will never be created, leaks a create watch.

packysauce commented 6 years ago

I'd also really appreciate any input on how to augment the tests to catch this kind of case. We've only seen it in prod, and I can't really think of a trivial repro.

packysauce commented 6 years ago

Hope everyone had a nice holiday, got a few moments to check out this PR?

packysauce commented 6 years ago

I'm not sure 1) Why that pypy test failed 2) How to make it run again to check for transient problems. Anyone get a chance to review my change?

packysauce commented 6 years ago

Alrighty, rebased and things are lookin happier

Thanks for the pro tips btw!

packysauce commented 6 years ago

Mind giving this a once over one more time?

jeffwidman commented 6 years ago

Thanks!