Skip to content

[Bug] Subscribing to topic executes work on the single threaded Pulsar metadata thread in some cases #23866

Open

Description

@lhotari

Search before asking

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

Version

All released versions

Minimal reproduce step

Subscribe to a topic when metadata isn't yet cached.

What did you expect to see?

The topic ordered executor to be used.

What did you see instead?

configuration-metadata-store executor was used:
Image
It's this executor:

this.executor = new ScheduledThreadPoolExecutor(1,
new DefaultThreadFactory(
StringUtils.isNotBlank(metadataStoreName) ? metadataStoreName : getClass().getSimpleName()));

Anything else?

No response

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Activity

  1. added
    type/bug
    on Jan 18, 2025
  2. added this to the 4.1.0 milestone on Jan 18, 2025
  3. self-assigned this
    on Jan 18, 2025
  4. modified the milestones: 4.1.0, 4.2.0 on Sep 8, 2025
  5. merlimat commented on Oct 24, 2026

    @merlimat
    Contributor

    Confirmed on current master. In ServerCnx.handleSubscribe (pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java:2383 on master), topic.subscribe(option) is chained with thenCompose onto BrokerService.isAllowAutoSubscriptionCreationAsync() (BrokerService.java:4903), which reads the namespace policies through getPoliciesAsync. On a cache miss that future completes on the configuration-metadata-store thread, so the subscribe and everything after it run on the single metadata thread. The likely fix is to switch to thenComposeAsync on the topic's ordered executor (or ctx.executor()) before calling topic.subscribe. ServerCnx.java:2837 (the producer's initial subscription) has the same pattern.

  6. added
    bug-verified
    on Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/brokerbug-verifiedtype/bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions