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

[fix][broker] Fix hash collision when using a consumer name that ends with a number #22053

Merged
merged 3 commits into from Feb 15, 2024

Conversation

lhotari
Copy link
Member

@lhotari lhotari commented Feb 14, 2024

Fixes #22050

Motivation

See #22050, there's a hash collision in ConsistentHashingStickyKeyConsumerSelector when the consumer name ends with a number for example "consumer1" and "consumer11" would collide for the key "consumer111" (consumer1, i=11 & consumer11, i=1).

Modifications

Fix hash collision by adding a separator between the 2 fields used in the hash calculation. Use the NUL character (\0) as a separator.

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

@lhotari lhotari added type/bug The PR fixed a bug or issue reported a bug ready-to-test release/3.0.3 release/3.2.1 labels Feb 14, 2024
@lhotari lhotari added this to the 3.3.0 milestone Feb 14, 2024
@lhotari lhotari self-assigned this Feb 14, 2024
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Feb 14, 2024
@lhotari lhotari changed the title [fix][bug] Fix hash collision when using a consumer name that ends with a number [fix][broker] Fix hash collision when using a consumer name that ends with a number Feb 14, 2024
Copy link
Contributor

@merlimat merlimat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 In the end, there would always be the possibility of conflict, though it would not impair the correctness. Even if we have 2 different keys hashing to the same bucket, one or the other consumer will get the messages, and with 100 points even few conflict shouldn't be skewing the assignments significantly.

@lhotari lhotari merged commit 7e73967 into apache:master Feb 15, 2024
50 checks passed
Technoboy- pushed a commit that referenced this pull request Feb 20, 2024
Technoboy- pushed a commit that referenced this pull request Feb 22, 2024
Technoboy- pushed a commit that referenced this pull request Feb 27, 2024
mukesh-ctds pushed a commit to datastax/pulsar that referenced this pull request Mar 1, 2024
mukesh-ctds pushed a commit to datastax/pulsar that referenced this pull request Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] collision while using ConsistentHashing & consumer name that end by a number
3 participants