-
Notifications
You must be signed in to change notification settings - Fork 7.3k
ZOOKEEPER-3546: Delete empty containers with cversion == 0 after a grace period #1091
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
ZOOKEEPER-3546: Delete empty containers with cversion == 0 after a grace period #1091
Conversation
|
| if (wasNewWithNoChildren) { | ||
| candidates.add(containerPath); | ||
| } else { | ||
| noChildrenAtLastCheck.add(containerPath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At a first glance we are only adding elements and never clearing the collection
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we do it outside of the getChildren().isEmpty() test. Children may have been added since the container was added to that collection, so we need to make sure that containers with children don't stay in it forever.
boolean wasNewWithNoChildren = noChildrenAtLastCheck.remove(containerPath);|
|
||
| assertNotNull("Container should still be there", zk.exists("/foo", false)); | ||
|
|
||
| containerManager.checkContainers(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid this sleep?
This test may turn into a flaky one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used the same approach as other tests in that class, where I understand that these sleep after each call to checkContainers are precisely there to avoid flakiness by giving time to the ZK server to asynchronously delete the nodes that have been selected for removal.
Did I miss something?
|
I second @maoling here that "If I create a container node which has not any children yet, it will never be deleted by the cleaning task, this behavior is expected." When a user create a container node he must prepare to create several children of it. Otherwise it is a misuse that the user should take care of the clean-up by himself. In an edge case that the creation of child fails, it is the responsibility of users to tolerate the failing case. Mainly my concern is if we introduce such grace period it becomes even worse users are now enforced to take care of an edge case caused by ZooKeeper: if they create a container first, following a creation of child which suffer network traffic and fails because of the grace period expire. Besides, I'm afraid it also affects how downstream project like Curator takes care of container znodes. cc @Randgalt |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also agree with @maoling and @tisonkun .
For me, it just makes more sense that an initialized container node does not get deleted. I wouldn't expect this to happen.
I personally also don't like the unconfigurable collection period TTL.
This is a behavioural change rather than a bug. If you want to change the behaviour, I think it should be first discussed with the community on [email protected]
|
Ok, I understand this is a feature rather than an unwanted side effect of giving time for application to create childrens, and I won't dispute that. What led to proposing this change is a problem we encountered when using Curator's I'm therefore closing this PR and the associated issue and will address this issue in Curator. |
|
Thanks for your update @swallez . Sounds interesting what Curator's |
|
Sorry - I missed the cc on this. I'll follow on Curator if @swallez opens an issue there. |
|
@tisonkun The problem in Curator is that those two nodes (container and |
|
@Randgalt creating an issue on Curator right now ;-) |
|
Yeah - I think it can be done in a transaction. The transaction APIs support TTL I'm pretty sure. |
|
Curator issue for reference: https://issues.apache.org/jira/browse/CURATOR-545 |
Ensures empty containers that never had children added are deleted after a grace period.
The grace period ensures that such empty containers live at for one full collection period. This gives clients time to create the container and add children in separate transactions even if the container is created right before the collection task is run.