Last active
August 29, 2015 14:18
-
-
Save Randgalt/9ba16461840006b76c7d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BACKGROUND | |
============ | |
A recurring problem for ZooKeeper users is garbage collection of parent nodes. Many recipes | |
(e.g. locks, leaders, etc.) call for the creation of a parent node under which participants | |
create sequential nodes. When the participant is done, it deletes its node. In practice, the | |
ZooKeeper tree begins to fill up with orphaned parent nodes that are no longer needed. The | |
ZooKeeper APIs don’t provide a way to clean these. Over time, ZooKeeper can become unstable | |
due to the number of these nodes. | |
CURRENT SOLUTIONS | |
=================== | |
Apache Curator has a workaround solution for this by providing the Reaper class which runs | |
in the background looking for orphaned parent nodes and deleting them. This isn’t ideal and | |
it would be better if ZooKeeper supported this directly. | |
PROPOSAL | |
========= | |
ZOOKEEPER-723 and ZOOKEEPER-834 have been proposed to allow EPHEMERAL nodes to contain | |
child nodes. This is not optimum as EPHEMERALs are tied to a session and the general | |
use case of parent nodes is for PERSISTENT nodes. This proposal adds a new node type, | |
CONTAINER. A CONTAINER node is the same as a PERSISTENT node with the additional property | |
that when its last child is deleted, it is deleted (and CONTAINER nodes recursively up | |
the tree are deleted if empty). | |
I have a first pass (untested) straw man proposal open for comment here: | |
https://github.com/apache/zookeeper/pull/28 | |
In order to have minimum impact on existing implementations, a container node is denoted | |
by having an ephemeralOwner id of Long.MIN_VALUE. This is pretty hackish, but I think it’s | |
the most supportable without causing disruption. Also, a container behaves a “little bit” | |
like an EPHEMERAL node so it isn’t totally illogical. Alternatively, a new field could be | |
added to STAT. | |
I look forward to feedback on this. If people think it’s worthwhile I’ll open a Jira and | |
work on a Production quality solution. If it’s rejected, I’d appreciate discussion of an | |
alternate as this is a real need in the ZK user community. | |
-Jordan |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment