Skip to content

Attempting to delete a tenant that was recently created sometimes fails with "MetadataStoreException: org.apache.zookeeper.KeeperException$NotEmptyException: KeeperErrorCode = Directory not empty for /admin/policies/$tenantname" #12553

Closed as not planned

Description

@zbentley

Describe the bug
When I create a tenant/namespace/topic/subscription and then immediately (seconds or less) try to delete them, I sometimes get a 500 response code and an internal stacktrace (see below).

To Reproduce
Run reproduction plan for #12551; sometimes no error will occur, sometimes the error described in that issue or others will occur, and sometimes this error will occur.

Expected behavior

  1. Tenant deletion should succeed if previous tenant creation succeeded, no matter how recently previous tenant creation was performed.
  2. This is probably more important: all operations related to deletion/creation of topics/namespaces/tenants conclude before the management API returns success codes to the user. This bug and the other similar ones I filed (see github links below) all seem to arise from CRUD operations with the management API being asynchronous: i.e. when I create/delete a tenant/topic/namespace, the actual side effects of that creation or deletion (e.g. adding/removing ledgers in BookKeeper, updating metadata in ZK) occur later, not during the API post. Not only is that bound to cause bugs like this, but it's also not what users expect; I would be happy to wait seconds or minutes for management API operations to complete in exchange for knowing that when they successfully complete that the thing I requested has actually been done.

Environment
Same environment as #12551

Stacktrace

URL: DELETE http://pulsar-blt-sn-platform-proxy-headless.pulsar:8080/admin/v2/tenants/blt3
Headers: Headers({'host': 'pulsar-blt-sn-platform-proxy-headless.pulsar:8080', 'accept': '*/*', 'accept-encoding': 'gzip, deflate', 'connection': 'keep-alive', 'user-agent': 'python-httpx/0.20.0'})
Payload: b''
 --- An unexpected error occurred in the server ---

Message: org.apache.pulsar.metadata.api.MetadataStoreException: org.apache.zookeeper.KeeperException$NotEmptyException: KeeperErrorCode = Directory not empty for /admin/policies/blt3

Stacktrace:

java.util.concurrent.CompletionException: org.apache.pulsar.metadata.api.MetadataStoreException: org.apache.zookeeper.KeeperException$NotEmptyException: KeeperErrorCode = Directory not empty for /admin/policies/blt3
	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:331)
	at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:346)
	at java.base/java.util.concurrent.CompletableFuture$UniRun.tryFire(CompletableFuture.java:777)
	at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506)
	at java.base/java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:2088)
	at org.apache.pulsar.metadata.impl.ZKMetadataStore.lambda$null$21(ZKMetadataStore.java:277)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: org.apache.pulsar.metadata.api.MetadataStoreException: org.apache.zookeeper.KeeperException$NotEmptyException: KeeperErrorCode = Directory not empty for /admin/policies/blt3
	at org.apache.pulsar.metadata.impl.ZKMetadataStore.getException(ZKMetadataStore.java:314)
	... 5 more
Caused by: org.apache.zookeeper.KeeperException$NotEmptyException: KeeperErrorCode = Directory not empty for /admin/policies/blt3
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:132)
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:54)
	at org.apache.pulsar.metadata.impl.ZKMetadataStore.getException(ZKMetadataStore.java:304)
	... 5 more

Activity

  1. added
    type/bug
    on Oct 31, 2021
  2. zbentley commented on Oct 31, 2021

    @zbentley
    ContributorAuthor

    The following issues were all observed in response to similar testing:
    apache/pulsar-client-cpp#86
    #12556
    #12555
    #12554
    #12553
    #12552
    #12551

    The condition that caused these issues to occur appears to be interaction with various pulsar entities (e.g. creating/deleting things in the management API, or attempting to create consumers) immediately after those entities were created or immediately after entities with the same name were deleted.

    I think the number of issues observed speaks to a defect in the management API functionality in general. Considering the severity of these issues (in many cases it is possible to force a topic/namespace into a permanently corrupted state), I hope a resolution can be found for the general/common root cause rather than fixing individual bug-inducing conditions.

    I suspect that the common root cause is that many management API operations are asynchronous that should not be.

    Ideally, the resolution of all of these issues would be the same: a management API operation--any operation--should not return successfully until all observable side effects of that operation across a Pulsar cluster (including brokers, proxies, bookies, and ZK) were completed. All caches of metadata (e.g. on all brokers/proxies in the cluster) related to the operation should be cleared, and all persistent state (including ledger deletion, bookie cleanup, ZooKeeper metadata, etc.) should be updated during management API operations, and not afterwards.

    If that means that management API operations take many seconds or minutes, that's still vastly preferable to not knowing when it is safe to interact with a cluster again after performing "DDL"-type changes.

  3. Technoboy- commented on Dec 8, 2021

    @Technoboy-
    Contributor

    The possible cause of this problem is that when tenants are being deleted, a new namespace is created, resulting in tenants having sub-nodes in the zk directory.

  4. github-actions commented on Feb 27, 2022

    @github-actions

    The issue had no activity for 30 days, mark with Stale label.

  5. zbentley commented on Apr 7, 2022

    @zbentley
    ContributorAuthor

    This does still repro on 2.9.1.

  6. fmiguelez commented on Apr 12, 2022

    @fmiguelez
    Contributor

    It also occurs on 2.9.2. This error was not produced on 2.7.4.

    Verified with our integration tests that perform at least a namespace recreation per test suite.

  7. fmiguelez commented on Apr 13, 2022

    @fmiguelez
    Contributor

    Also verified with 2.10.0. Namespace reaches a situation when it can no longer be removed.

    $ curl -X DELETE http://localhost:8081/admin/v2/namespaces/dbus/test?force=true
    
     --- An unexpected error occurred in the server ---
    
    Message: org.apache.zookeeper.KeeperException$NotEmptyException: KeeperErrorCode = Directory not empty for /namespace/dbus/test
    
    Stacktrace:
    
    org.apache.pulsar.metadata.api.MetadataStoreException: org.apache.zookeeper.KeeperException$NotEmptyException: KeeperErrorCode = Directory not empty for /namespace/dbus/test
            at org.apache.pulsar.metadata.impl.ZKMetadataStore.getException(ZKMetadataStore.java:432)
            at org.apache.pulsar.metadata.impl.ZKMetadataStore.handleDeleteResult(ZKMetadataStore.java:268)
            at org.apache.pulsar.metadata.impl.ZKMetadataStore.lambda$batchOperation$6(ZKMetadataStore.java:180)
            at org.apache.pulsar.metadata.impl.PulsarZooKeeperClient$3$1.processResult(PulsarZooKeeperClient.java:490)
            at org.apache.zookeeper.ClientCnxn$EventThread.processEvent(ClientCnxn.java:722)
            at org.apache.zookeeper.ClientCnxn$EventThread.run(ClientCnxn.java:563)
    Caused by: org.apache.zookeeper.KeeperException$NotEmptyException: KeeperErrorCode = Directory not empty for /namespace/dbus/test
            at org.apache.zookeeper.KeeperException.create(KeeperException.java:132)
            at org.apache.zookeeper.KeeperException.create(KeeperException.java:54)
            at org.apache.pulsar.metadata.impl.ZKMetadataStore.getException(ZKMetadataStore.java:422)
            ... 5 more
    

    We have also verified that restarting Pulsar allows namespace deletion to proceed (is there any cleanup process on startup?).

  8. fmiguelez commented on Apr 13, 2022

    @fmiguelez
    Contributor

    @sijie can someone else take a look at this?

  9. lhotari commented on May 23, 2023

    @lhotari
    Member

    Flaky test issue #20376 has similar exception

  10. merlimat commented on Oct 24, 2026

    @merlimat
    Contributor

    Thanks @zbentley for the report. This was reported on a Pulsar release before 3.0, which is no longer supported; the supported releases are 4.0.x, 4.2.x and 5.0.x. Much of the code involved has changed since, and the problem hasn't been confirmed on a current release, so I'm closing it as part of cleaning up old reports. If you still see it on a supported release, please open a new issue with the version and steps to reproduce, and link this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions