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/11/10 08:23:08 UTC

[GitHub] [pulsar] codelipenghui commented on a change in pull request #12711: Fix znode leakage caused by deleting tenant

codelipenghui commented on a change in pull request #12711:
URL: https://github.com/apache/pulsar/pull/12711#discussion_r746340573



##########
File path: pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/NamespaceResources.java
##########
@@ -122,6 +123,16 @@ public static boolean pathIsFromNamespace(String path) {
                 && path.substring(BASE_POLICIES_PATH.length() + 1).contains("/");
     }
 
+    // clear resource of `/namespace/{namespaceName}` for zk-node
+    public void clearNamespace(NamespaceName ns) throws MetadataStoreException {

Review comment:
       ```suggestion
       public void deleteNamespace(NamespaceName ns) throws MetadataStoreException {
   ```

##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/TenantsBase.java
##########
@@ -269,6 +270,23 @@ protected void internalDeleteTenant(AsyncResponse asyncResponse, String tenant)
                         asyncResponse.resume(new RestException(ex));
                         return null;
                     });
+
+                    // After clearing TenantResources, we need to clear the information of zk-node at the same time
+                    try {
+                        pulsar().getPulsarResources().getTopicResources().clearTenantPersistence(tenant).get();

Review comment:
       Avoid calling a block method in a async callback.

##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/TenantsBase.java
##########
@@ -269,6 +270,23 @@ protected void internalDeleteTenant(AsyncResponse asyncResponse, String tenant)
                         asyncResponse.resume(new RestException(ex));
                         return null;
                     });
+
+                    // After clearing TenantResources, we need to clear the information of zk-node at the same time
+                    try {
+                        pulsar().getPulsarResources().getTopicResources().clearTenantPersistence(tenant).get();

Review comment:
       Please check all.

##########
File path: pulsar-broker-common/src/main/java/org/apache/pulsar/broker/resources/NamespaceResources.java
##########
@@ -122,6 +123,16 @@ public static boolean pathIsFromNamespace(String path) {
                 && path.substring(BASE_POLICIES_PATH.length() + 1).contains("/");
     }
 
+    // clear resource of `/namespace/{namespaceName}` for zk-node
+    public void clearNamespace(NamespaceName ns) throws MetadataStoreException {
+        delete(joinPath(OWNER_INFO_ROOT, ns.toString()));
+    }
+
+    // clear resource of `/namespace/{tenant}` for zk-node
+    public void clearTenant(String tenant) throws MetadataStoreException {

Review comment:
       ```suggestion
       public void deleteTenant(String tenant) throws MetadataStoreException {
   ```




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