Skip to content

Conversation

@merlimat
Copy link
Contributor

Motivation

When using a multi-topic consumer, either through the regex or by passing a list of topics, we are ending up checking the partitioned topic metadata every 1 min, even if the topics are not partitioned.

We don't need to re-check that information if the topics are not partitioned. Also, this can be causing a lot of read traffic on ZK since we keep checking that "partitioned-metadata" that these topics don't have and, in 2.7, this information is not cached in brokers when the metadata is not found.

Modifications

When adding non-partitioned topics to the multi-topic consumer, use 0 for partitions when the topic is not partitioned in order to skip the periodic re-check of the partitions count.

@merlimat merlimat added type/bug The PR fixed a bug or issue reported a bug release/2.7.3 labels May 26, 2021
@merlimat merlimat added this to the 2.8.0 milestone May 26, 2021
@merlimat merlimat self-assigned this May 26, 2021
Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

I left a minor comment

.collect(Collectors.toList());
} else {
boolean isTopicBeingSubscribedForInOtherThread = this.topics.putIfAbsent(topicName, 1) != null;
boolean isTopicBeingSubscribedForInOtherThread = this.topics.putIfAbsent(topicName, 0) != null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to create a constant for this magic value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Added constant

@merlimat merlimat merged commit 9eb173a into apache:master May 29, 2021
wangjialing218 pushed a commit to wangjialing218/pulsar that referenced this pull request May 31, 2021
…etadata (apache#10708)

* On multi-topic consumer, we shouldn't keep checking the partitioned metadata

* Added NON_PARTITIONED constant

* Removed assertion that is now invalid

* Fixed handling of deleted partitioned topic

* Fixed re-subscribing same topic
yangl pushed a commit to yangl/pulsar that referenced this pull request Jun 23, 2021
…etadata (apache#10708)

* On multi-topic consumer, we shouldn't keep checking the partitioned metadata

* Added NON_PARTITIONED constant

* Removed assertion that is now invalid

* Fixed handling of deleted partitioned topic

* Fixed re-subscribing same topic
Technoboy- added a commit to Technoboy-/pulsar that referenced this pull request Jun 30, 2021
Technoboy- added a commit to Technoboy-/pulsar that referenced this pull request Jun 30, 2021
Technoboy- added a commit to Technoboy-/pulsar that referenced this pull request Jun 30, 2021
@merlimat merlimat deleted the avoid-recurring-partitioned-topic-metadata branch June 30, 2021 16:17
codelipenghui pushed a commit that referenced this pull request Jul 1, 2021
…partitioned metadata (#11168)

Pick #10708 to branch 2.7.

### Motivation

When using a multi-topic consumer, either through the regex or by passing a list of topics, we are ending up checking the partitioned topic metadata every 1 min, even if the topics are not partitioned. 

We don't need to re-check that information if the topics are not partitioned. Also, this can be causing a lot of read traffic on ZK since we keep checking that "partitioned-metadata" that these topics don't have and, in 2.7, this information is not cached in brokers when the metadata is not found. 

### Modifications

When adding non-partitioned topics to the multi-topic consumer, use 0 for partitions when the topic is not partitioned in order to skip the periodic re-check of the partitions count.
@codelipenghui codelipenghui added the cherry-picked/branch-2.7 Archived: 2.7 is end of life label Jul 4, 2021
jerrypeng pushed a commit to jerrypeng/incubator-pulsar that referenced this pull request Nov 4, 2021
…etadata (apache#10708)

* On multi-topic consumer, we shouldn't keep checking the partitioned metadata

* Added NON_PARTITIONED constant

* Removed assertion that is now invalid

* Fixed handling of deleted partitioned topic

* Fixed re-subscribing same topic
bharanic-dev pushed a commit to bharanic-dev/pulsar that referenced this pull request Mar 18, 2022
…etadata (apache#10708)

* On multi-topic consumer, we shouldn't keep checking the partitioned metadata

* Added NON_PARTITIONED constant

* Removed assertion that is now invalid

* Fixed handling of deleted partitioned topic

* Fixed re-subscribing same topic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-picked/branch-2.7 Archived: 2.7 is end of life release/2.7.3 type/bug The PR fixed a bug or issue reported a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants