apache / pulsar

Apache Pulsar - distributed pub-sub messaging system
https://pulsar.apache.org/
Apache License 2.0
14.26k stars 3.59k forks source link

[Bug] ConsistentHashingStickyKeyConsumerSelector's getConsumerKeyHashRanges doesn't return correct results #23321

Closed lhotari closed 1 month ago

lhotari commented 2 months ago

Search before asking

Read release policy

Version

all versions

Minimal reproduce step

After the last entry in the hash ring, it wraps around to the first entry: https://github.com/apache/pulsar/blob/7e73967f9daf368562fa0318d4ecb62272d72174/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ConsistentHashingStickyKeyConsumerSelector.java#L123-L125

This is ignored in the getConsumerKeyHashRanges method: https://github.com/apache/pulsar/blob/7e73967f9daf368562fa0318d4ecb62272d72174/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ConsistentHashingStickyKeyConsumerSelector.java#L138-L145

Another problem is that the rule to pick one consumer when there are hash collisions is also ignored: https://github.com/apache/pulsar/blob/7e73967f9daf368562fa0318d4ecb62272d72174/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ConsistentHashingStickyKeyConsumerSelector.java#L127

What did you expect to see?

the results returned by the getConsumerKeyHashRanges should be accurate and correct

What did you see instead?

the getConsumerKeyHashRanges logic

Anything else?

No response

Are you willing to submit a PR?

lhotari commented 1 month ago

This will be included in #23327 since the implementation was needed for tests in that PR.

lhotari commented 1 month ago

Issue #16654 is related.