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

Consumer cannot consume messages when key_shared mode and subscriptionKeySharedUseConsistentHashing #10750

Closed
sourcelliu opened this issue May 31, 2021 · 2 comments · Fixed by #13991
Labels
type/bug The PR fixed a bug or issue reported a bug
Milestone

Comments

@sourcelliu
Copy link
Contributor

Describe the bug
Key_shared mode is configured as ConsistentHashingStickyKeyConsumerSelector, When I use three consumers with the same consumerName, if one consumer is closed, the other two consumers will no longer be able to consume messages.

To Reproduce
Steps to reproduce the behavior:

  1. config the 'conf/standalone.conf'
     subscriptionKeySharedUseConsistentHashing=true
    
  2. ./bin/pulsar standalone
  3. Start 3 consumers with the same cosumerName.
        PulsarClient client = PulsarClient.builder()
                .serviceUrl("pulsar://localhost:6650")
                .build();

        org.apache.pulsar.client.api.Consumer consumer = client.newConsumer()
                .topic("my-topic")
                .subscriptionName("my-subscription")
                .consumerName("one")
                .subscriptionType(SubscriptionType.Key_Shared)
                .subscribe();
  1. Start a producer send messages.
  2. All 3 consumers can consume messages.
  3. Close one consumer, and the producer send messages again.
  4. The other two consumers cannot consume new messages

Expected behavior
The other two consumers can continue to consume new messages(Refer to step 7 above).

Additional context

I think the problem is due to the above code, which removes all consumers with the same name.

@sourcelliu sourcelliu added the type/bug The PR fixed a bug or issue reported a bug label May 31, 2021
@eolivelli eolivelli changed the title Consumer cannot consume messages when key_shared mode Consumer cannot consume messages when key_shared mode and ConsistentHashingStickyKeyConsumerSelector Jan 27, 2022
@lhotari
Copy link
Member

lhotari commented Jan 27, 2022

Perhaps this is related to #13965 ?

@eolivelli eolivelli changed the title Consumer cannot consume messages when key_shared mode and ConsistentHashingStickyKeyConsumerSelector Consumer cannot consume messages when key_shared mode and subscriptionKeySharedUseConsistentHashing Jan 27, 2022
@merlimat
Copy link
Contributor

@sourcelliu @lhotari

Perhaps this is related to #13965 ?

No, it's not related to that (and #13965 is just a test issue, not a code issue).

The consumer name is expected to be unique (eg: if you don't pass one, it will be auto-generated).

Having said that, the check here is wrong, as we should compare the consumer instance and not just the name.

codelipenghui pushed a commit that referenced this issue Jan 28, 2022
…r with consistent hashing (#13991)

### Motivation

Fixes #10750

When removing consumers from the key-shared selector based on the consistent hashing, we were removing by consumer name, although there can be duplicated consumer names (even though is not recommended).
@merlimat merlimat added this to the 2.10.0 milestone Jan 28, 2022
codelipenghui pushed a commit that referenced this issue Jan 29, 2022
…r with consistent hashing (#13991)

Fixes #10750

When removing consumers from the key-shared selector based on the consistent hashing, we were removing by consumer name, although there can be duplicated consumer names (even though is not recommended).

(cherry picked from commit 8360d45)
Nicklee007 pushed a commit to Nicklee007/pulsar that referenced this issue Apr 20, 2022
…r with consistent hashing (apache#13991)

### Motivation

Fixes apache#10750

When removing consumers from the key-shared selector based on the consistent hashing, we were removing by consumer name, although there can be duplicated consumer names (even though is not recommended).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug The PR fixed a bug or issue reported a bug
Projects
None yet
3 participants