Skip to content

[Bug] Applying Pulsar Topic Policies fails when multiple policies are updated in a short period of time #24393

Closed

Description

@shasank112001

Search before reporting

  • I searched in the issues and found nothing similar.

Read release policy

  • I understand that unsupported versions don't get bug fixes. I will attempt to reproduce the issue on a supported version of Pulsar client and Pulsar broker.

User environment

Pulsar Version = 4.0.3
OS = Linux
Java Version = 21
Client Library Version = 4.0.3 (Pulsar-Admin)
Client OS = Darwin (Mac)
Client Java Version = 21

Issue Description

I have a function to create topics and apply policies on that topic.

admin.topicPolicies().setInactiveTopicPolicies(pulsarTopic, policies.inactive_topic_policies);

admin.topics().setReplicationClusters(pulsarTopic, List.of("cluster-a", "cluster-b"));

admin.topicPolicies().setSubscriptionTypesEnabledAsync(pulsarTopic, Set.of(SubscriptionType.Shared));

admin.topics().updateProperties(pulsarTopic, policies.properties);

However, after applying these, when I verify the results I get mismatching results:

  1. replication clusters is null (if I do with "applied"=true, I only get 1 cluster name)
  2. subscriptionTypesEnabled = [].

If I introduce a 1 second delay between each of the commands using Thread.sleep(1000), then I don't get these errors.

Also the following order of commands works as well :

admin.topics().setReplicationClusters(pulsarTopic, List.of("cluster-a", "cluster-b"));

admin.topicPolicies().setInactiveTopicPolicies(pulsarTopic, policies.inactive_topic_policies);

admin.topics().updateProperties(pulsarTopic, policies.properties);

admin.topicPolicies().setSubscriptionTypesEnabledAsync(pulsarTopic, Set.of(SubscriptionType.Shared));

I believe this might be a result of Async policy application on the broker.

Error messages

No error messages are observed. Each  POST call succeeds with a 204.

Reproducing the issue

You can run the two method call orderings and verify the results.

Additional information

No response

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Activity

  1. added
    type/bug
    on Jun 6, 2025
  2. lhotari commented on Jun 6, 2025

    @lhotari
    Member

    Possibly related to #21303.

  3. shasank112001 commented on Jun 6, 2025

    @shasank112001
    ContributorAuthor

    Seems to be related, must have missed that issue during my search. Any plans on fixing this? I was also wondering, why topic policies are not updated in a similar fashion to namespaces. It seems all policies on topics are almost the same as namespaces, If we were to consolidate the update into one call, the changes could be better managed. What do you think?

  4. lhotari commented on Jun 6, 2025

    @lhotari
    Member

    Seems to be related, must have missed that issue during my search. Any plans on fixing this? I was also wondering, why topic policies are not updated in a similar fashion to namespaces. It seems all policies on topics are almost the same as namespaces, If we were to consolidate the update into one call, the changes could be better managed. What do you think?

    I hope this gets more attention and gets fixed soon. Topic policies aren't stored in the Metadata store and perhaps that's one of the reasons why exactly the same solution as there was for namespaces cannot be directly applied to topic policies.

  5. lhotari commented on Jun 18, 2025

    @lhotari
    Member

    WIP fix in #24427

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