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

Optionally support ZNodes of type 'container' when creating locks #4

Open
mstyne opened this issue Apr 29, 2015 · 5 comments
Open

Optionally support ZNodes of type 'container' when creating locks #4

mstyne opened this issue Apr 29, 2015 · 5 comments

Comments

@mstyne
Copy link
Contributor

mstyne commented Apr 29, 2015

Hello again @Gutza!

When a lock, say:

/mstyne/test/lock-0000000001

is released, the parent node

/mstyne/test

is left behind. Is there some reason for doing this that I might not be aware of as a non Zookeeper-guru? Would it be inadvisable to allow for an option to remove the parent node as well? Would using an ephemeral node for locking purposes be a Bad Idea?

If this seems like it might be a reasonable addition to you, I'll see about putting together a pull request.

Let me know what you think, and thanks.

Mike

@Gutza
Copy link
Owner

Gutza commented Apr 29, 2015

It could be optionally released, but I think for most practical use cases it would be desirable to keep it – I tend to associate parent nodes with database records, e.g. /myProject/userProfile22/lock-0000000001; sooner or later I'll need to lock that user profile again, so I don't think it's worth deleting and recreating those. Also, if you're considering deleting empty parent nodes it would make sense to consider deleting empty grandparent nodes, grand-grandparent nodes and so on (at least for completeness); I'm not sure how much usefulness could be extracted from that (but of course, YMMV).

Using ephemeral nodes for locking is a Good Idea (tm) – in fact, NOT using ephemeral nodes is a Bad Idea. When your execution thread dies because of an exception you want to make sure your lock dies as well – and you can only ensure that reliably with ephemeral nodes. Otherwise you risk having your thread die and your lock persist indefinitely.

Best,
Bogdan

@mstyne mstyne closed this as completed Apr 29, 2015
@mstyne
Copy link
Contributor Author

mstyne commented Apr 29, 2015

Didn't mean to close this; thanks for the insight, Bogdan!

@mstyne mstyne reopened this Apr 29, 2015
@Gutza
Copy link
Owner

Gutza commented Apr 29, 2015

No worries – exceptions happen. :-)

@mstyne
Copy link
Contributor Author

mstyne commented Jun 5, 2015

Laziness prevails!

https://issues.apache.org/jira/browse/ZOOKEEPER-2163

I suppose once this makes it into a release, it can be optionally be used as a node type when creating a lock.

@mstyne mstyne changed the title Optionally remove parent node when lock is released / Ephemeral nodes Optionally support ZNodes of type 'container' when creating locks Jun 5, 2015
@mstyne
Copy link
Contributor Author

mstyne commented Aug 11, 2015

Looks like this will be in Zookeeper 3.5.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants