You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/09/04 23:40:11 UTC

[GitHub] [pulsar] merlimat opened a new pull request #11925: Use ZK "container" types for intermediate z-nodes

merlimat opened a new pull request #11925:
URL: https://github.com/apache/pulsar/pull/11925


   ### Motivation
   
   When creating intermediate nodes in ZooKeeper we can mark them as "container" nodes. This is a new type introduced in ZK 3.5 that will ensure these nodes will get auto-deleted when the last child is deleted (the cleanup is done periodically).
   
   This will allow to do proper cleanup of directory structures in ZK even in presence of failures.
   
   We cannot immediately remove the existing logics that try to manually get rid of them, since for existing clusters these nodes would not get auto-deleted.


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

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] eolivelli commented on a change in pull request #11925: Use ZK "container" types for intermediate z-nodes

Posted by GitBox <gi...@apache.org>.
eolivelli commented on a change in pull request #11925:
URL: https://github.com/apache/pulsar/pull/11925#discussion_r702390310



##########
File path: pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/ZKMetadataStore.java
##########
@@ -441,4 +439,41 @@ public long getZkSessionId() {
         }
         return CompletableFuture.completedFuture(null);
     }
+
+    private static void asyncCreateFullPathOptimistic(final ZooKeeper zk, final String originalPath, final byte[] data,
+                                                      final CreateMode createMode,
+                                                      final AsyncCallback.StringCallback callback) {
+        zk.create(originalPath, data, ZooDefs.Ids.OPEN_ACL_UNSAFE, createMode, (rc, path, ctx, name) -> {
+            if (rc != Code.NONODE.intValue()) {
+                callback.processResult(rc, path, ctx, name);
+            } else {
+                String parent = (new File(originalPath)).getParent().replace("\\", "/");
+
+                // Create parent nodes as "CONTAINER" so that ZK will automatically delete them when they're empty

Review comment:
       Can we add here a nite that old clusters may still have the old type?




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

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] eolivelli merged pull request #11925: Use ZK "container" types for intermediate z-nodes

Posted by GitBox <gi...@apache.org>.
eolivelli merged pull request #11925:
URL: https://github.com/apache/pulsar/pull/11925


   


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

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org