Skip to content

[Bug] Broker internal error while deleting namespace #18802

Description

@nicoloboschi

Search before asking

  • I searched in the issues and found nothing similar.

Version

2.11.0

Minimal reproduce step

Only with topicLevelPoliciesEnabled=true

Test case

@Test
    public void testDeleteNamespaceWithTopicPolicies() throws Exception {
        stopBroker();
        conf.setSystemTopicEnabled(true);
        conf.setTopicLevelPoliciesEnabled(true);
        conf.setForceDeleteNamespaceAllowed(true);
        setup();

        String namespace = tenant + "/test-ns2";
        admin.namespaces().createNamespace(namespace, Sets.newHashSet("test"));
        admin.topics().createNonPartitionedTopic(namespace + "/topictest");
        admin.namespaces().deleteNamespace(namespace, true);
022-12-07T15:27:32,863+0100 [pulsar-io-95-5] WARN  org.apache.pulsar.broker.service.ServerCnx - Failed to get Partitioned Metadata [/127.0.0.1:57885] persistent://test-tenant/test-ns2/__change_events: Namespace is deleted
org.apache.pulsar.broker.web.RestException: Namespace is deleted

What did you expect to see?

The namespace being deleted correctly.

What did you see instead?

I get an internal error from the broker.

The issue is that the __change_events topic doesn't exists at the moment of the namespace deletion.
The namespace deletion procedure is:

  • set namespace deleted=true (disallow new topics being created)
  • delete user topics
  • delete system topics

Right after deleting the first topic, the notification of the topic deleted is written to the __change_events. If the topic doesn't exists it's created. But at this point the topic creation is not allowed.

I think in case of namespace deletion all the notifications shouldn't be written at all since the topic is being deleted.

Anything else?

No response

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugThe PR fixed a bug or issue reported a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions