You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@zookeeper.apache.org by GitBox <gi...@apache.org> on 2019/09/17 11:31:34 UTC

[GitHub] [zookeeper] eolivelli commented on a change in pull request #1091: ZOOKEEPER-3546: Delete empty containers with cversion == 0 after a grace period

eolivelli commented on a change in pull request #1091: ZOOKEEPER-3546: Delete empty containers with cversion == 0 after a grace period
URL: https://github.com/apache/zookeeper/pull/1091#discussion_r325115877
 
 

 ##########
 File path: zookeeper-server/src/main/java/org/apache/zookeeper/server/ContainerManager.java
 ##########
 @@ -139,14 +140,22 @@ protected long getMinIntervalMs() {
         Set<String> candidates = new HashSet<String>();
         for (String containerPath : zkDb.getDataTree().getContainers()) {
             DataNode node = zkDb.getDataTree().getNode(containerPath);
-            /*
-                cversion > 0: keep newly created containers from being deleted
-                before any children have been added. If you were to create the
-                container just before a container cleaning period the container
-                would be immediately be deleted.
-             */
-            if ((node != null) && (node.stat.getCversion() > 0) && (node.getChildren().isEmpty())) {
-                candidates.add(containerPath);
+            boolean wasNewWithNoChildren = noChildrenAtLastCheck.remove(containerPath);
+
+            if (node != null && node.getChildren().isEmpty()) {
+                if (node.stat.getCversion() == 0) {
+                    // Give newly created containers a grace period and avoid deleting
+                    // them before any children could be added. If you were to create the
+                    // container just before a container cleaning period the container
+                    // would be immediately be deleted.
+                    if (wasNewWithNoChildren) {
+                        candidates.add(containerPath);
+                    } else {
+                        noChildrenAtLastCheck.add(containerPath);
 
 Review comment:
   At a first glance we are only adding elements and never clearing the collection

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services