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/11/22 22:52:54 UTC

[GitHub] [zookeeper] lvfangmin commented on a change in pull request #1138: ZOOKEEPER-3546 - Allow optional deletion of never used Container Nodes

lvfangmin commented on a change in pull request #1138: ZOOKEEPER-3546 - Allow optional deletion of never used Container Nodes
URL: https://github.com/apache/zookeeper/pull/1138#discussion_r349825800
 
 

 ##########
 File path: zookeeper-server/src/main/java/org/apache/zookeeper/server/ContainerManager.java
 ##########
 @@ -139,12 +160,26 @@ 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.getChildren().isEmpty()) {
+                /*
+                    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.stat.getCversion() > 0) {
+                    candidates.add(containerPath);
+                } else {
+                    /*
+                        Users may not want unused containers to live indefinitely. Allow a system
+                        property to be set that sets the max time for a cversion-0 container
+                        to stay before being deleted
+                     */
+                    if ((maxNeverUsedIntervalMs != 0) && (getElapsed(node) > maxNeverUsedIntervalMs)) {
+                        candidates.add(containerPath);
 
 Review comment:
   It would be great if we can add some visibility to track container being deleted because of this? Maybe add a log or metric?

----------------------------------------------------------------
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