[Bug] topicsPattern cannot subscribe to non-persistent topics
- Dominant language
- Java
- Stars
- 15.3k
- Forks
- 3.8k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 160
Description
### Search before asking
- [X] I searched in the [issues](https://github.com/apache/pulsar/issues) and found nothing similar.
### Version
ApachePulsar 2.11.0
### Minimal reproduce step
```java
pulsarClient.newConsumer()
.subscriptionName("my-sub")
.topicsPattern("public/default/.*")
.subscriptionTopicsMode(RegexSubscriptionMode.NonPersistentOnly)
.subscribe();
```
### What did you expect to see?
Ability to subscribe to non-persistent topics
### What did you see instead?
Not subscribed to non-persistent topics. After DEBUG, it was found that the Topic list could not be obtained from Broker:
```java
// The topicsList is empty
List topicsList = getTopicsResult.getTopics();
if (!getTopicsResult.isFiltered()) {
topicsList = TopicList.filterTopics(getTopicsResult.getTopics(), conf.getTopicsPattern());
}
conf.getTopicNames().addAll(topicsList);
ConsumerBase consumer = new PatternMultiTopicsConsumerImpl<>(conf.getTopicsPattern(),
getTopicsResult.getTopicsHash(),
PulsarClientImpl.this,
conf,
externalExecutorProvider,
consumerSubscribedFuture,
schema, subscriptionMode, interceptors);
consumers.add(consumer);
```
It appears that information on non-persistent topics is not synchronized across the cluster. My cluster has a total of three nodes. The non-persistent topic list was not obtained during the first two startups, but it obtained da during the third startup.
### Anything else?
_No response_
### Are you willing to submit a PR?
- [ ] I'm willing to submit a PR!
Contributor guide
Research direction
Reproduce the Java snippet using topicsPattern("public/default/.*") and NonPersistentOnly, then trace PatternMultiTopicsConsumerImpl, TopicList, and getTopicsResult handling. Compare broker topic discovery across the three-node cluster; done means the consumer consistently subscribes to matching non-persistent topics from startup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100