Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[broker] Consumer is registered on dispatcher even if hash range conflicts on Key_Shared subscription #7444

Merged
merged 1 commit into from
Jul 6, 2020

Conversation

massakam
Copy link
Contributor

@massakam massakam commented Jul 3, 2020

Motivation

If hash ranges specified by multiple consumers conflict on a Key_Shared subscription, the consumer that connects later will fail to subscribe. When this happens, the consumer that should have failed to subscribe is added to the topic stats. These "non-existent" consumers will not disappear until the broker server is restarted.

When the hash ranges conflict, an exception is thrown from HashRangeExclusiveStickyKeyConsumerSelector#addConsumer(). However, at that time, the addition of the consumer to consumerList and consumerSet of the dispatcher has already been completed, and it will not be removed.

public synchronized void addConsumer(Consumer consumer) throws BrokerServiceException {
super.addConsumer(consumer);
selector.addConsumer(consumer);

Modifications

If an exception is thrown from HashRangeExclusiveStickyKeyConsumerSelector#addConsumer(), remove the consumer added to consumerList and consumerSet.

@massakam massakam added type/bug The PR fixed a bug or issue reported a bug area/broker labels Jul 3, 2020
@massakam massakam added this to the 2.7.0 milestone Jul 3, 2020
@massakam massakam self-assigned this Jul 3, 2020
@merlimat merlimat merged commit 97ee82e into apache:master Jul 6, 2020
@massakam massakam deleted the fix-consumer-increasing branch July 7, 2020 01:32
codelipenghui pushed a commit to streamnative/pulsar-archived that referenced this pull request Jul 14, 2020
wolfstudy pushed a commit that referenced this pull request Jul 29, 2020
…Key_Shared subscription (#7444)

(cherry picked from commit 97ee82e)
huangdx0726 pushed a commit to huangdx0726/pulsar that referenced this pull request Aug 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/broker release/2.6.1 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.

2 participants