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

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

Closed
2 of 3 tasks
lhotari opened this issue Sep 19, 2024 · 2 comments · Fixed by #23327
Closed
2 of 3 tasks
Assignees
Labels
type/bug The PR fixed a bug or issue reported a bug

Comments

@lhotari
Copy link
Member

lhotari commented Sep 19, 2024

Search before asking

  • I searched in the issues and found nothing similar.

Read release policy

  • I understand that unsupported versions don't get bug fixes. I will attempt to reproduce the issue on a supported version of Pulsar client and Pulsar broker.

Version

all versions

Minimal reproduce step

After the last entry in the hash ring, it wraps around to the first entry:

} else {
consumerList = hashRing.firstEntry().getValue();
}

This is ignored in the getConsumerKeyHashRanges method:

int start = 0;
for (Map.Entry<Integer, List<Consumer>> entry: hashRing.entrySet()) {
for (Consumer consumer: entry.getValue()) {
result.computeIfAbsent(consumer, key -> new ArrayList<>())
.add(Range.of(start, entry.getKey()));
}
start = entry.getKey() + 1;
}

Another problem is that the rule to pick one consumer when there are hash collisions is also ignored:

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

  • ignores the "hash ring" wrap around after the last entry
  • ignores the logic for choosing a single entry when there's a hash collision
    • this is a conflicting goal currently since for hash collisions, the target consumer is selected based on the input hash
      • for hash ranges with multiple consumers, it would be necessary to scan the complete range to find out the actual hash ranges for a consumer

Anything else?

No response

Are you willing to submit a PR?

  • I'm willing to submit a PR!
@lhotari
Copy link
Member Author

lhotari commented Sep 20, 2024

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

@lhotari
Copy link
Member Author

lhotari commented Oct 4, 2024

Issue #16654 is related.

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
Development

Successfully merging a pull request may close this issue.

6 participants