Skip to content

Consumer cannot consume messages when key_shared mode and subscriptionKeySharedUseConsistentHashing #10750

Closed

Description

@sourcelliu

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.

Activity

  1. added
    type/bug
    on May 31, 2021
  2. changed the title [-]Consumer cannot consume messages when key_shared mode [/-] [+]Consumer cannot consume messages when key_shared mode and ConsistentHashingStickyKeyConsumerSelector[/+] on Jan 27, 2022
  3. lhotari commented on Jan 27, 2022

    @lhotari
    Member

    Perhaps this is related to #13965 ?

  4. changed the title [-]Consumer cannot consume messages when key_shared mode and ConsistentHashingStickyKeyConsumerSelector[/-] [+]Consumer cannot consume messages when key_shared mode and subscriptionKeySharedUseConsistentHashing[/+] on Jan 27, 2022
  5. merlimat commented on Jan 27, 2022

    @merlimat
    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.

  6. added a commit that references this issue on Jan 28, 2022
    8360d45
  7. added this to the 2.10.0 milestone on Jan 28, 2022
  8. added a commit that references this issue on Jan 29, 2022
    df232a0
  9. added a commit that references this issue on Apr 20, 2022
    e427273
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions