zbentley opened a new issue, #15705: URL: https://github.com/apache/pulsar/issues/15705
**Describe the bug** If a KeyShared consumer has any unacknowledged messages, new KeyShared consumers on the same subscription after that point will not get any new messages (even messages with brand new keys) until the original consumer either disconnects or acks/nacks some indeterminate number of messages. This is a really bad bug! **Bug scenario 1** 1. Create a **non partitioned** topic. 2. Create a KeyShared subscription on that topic. 3. Produce some number of messages on the topic with a given key, say `key1`, using a KeyBased batching strategy. 4. Start a consumer on the topic with the below code and ensure it prints `Press a key to acknowledge messages`. 5. Start a second consumer on the same topic, ensure it does not print `Press a key to acknowledge messages` (first consumer owns the key). 6. Produce some number (10 should be sufficient) of messages on the topic with unique keys not equal to `key1`; say `key2`, `key3`, and so on. The goal here is to get a key that hashes to the second consumer's range. 7. Observe that the second consumer never gets a message. 8. In the first consumer's terminal, press enter. 9. As the first consumer acks messages, observe that only then does the second consumer get any messages. **Bug scenario 2** 1. Create a **non partitioned** topic. 2. Create a KeyShared subscription on that topic. 3. Produce 100 messages on that topic, each with a distinct partition key (e.g. `key1`, `key2` through `key100`). 4. Start a consumer on the topic with the below code and ensure it prints `Press a key to acknowledge messages`. 5. Start a second consumer on the topic with the below code. 6. Observe that the second consumer does not receive any messages (i.e. it does not print `Press a key to acknowledge messages`), even though [hash range redistribution](https://medium.com/@ankushkhanna1988/apache-pulsar-key-shared-mode-sticky-consistent-hashing-a4ee7133930a) should have allocated at least some of the 100 keys to the new consumer. 8. In the first consumer's terminal, press enter. 9. As the first consumer acks messages, observe that only then does the second consumer get any messages. **Expected behavior** In scenario 1, the second consumer should receive at least some messages in step 6. In scenario 2, the second consumer should receive messages as soon as it starts. In short, **I think hash range redistribution is not working right, or is not triggering message re-routing:** when new KeyShared consumers arrive, two things should happen: 1. New consumers should be allocated part of the hash range of their subscription. 2. Any backlog messages for keys in that range should be sent to the new consumer. Part 1 is working, but I think part 2 is not. **Environment:** Same environment as https://github.com/apache/pulsar/issues/15701 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
