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 out-of-order issues with ConsistentHashingStickyKeyConsumerSelector #23327

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

lhotari
Copy link
Member

@lhotari lhotari commented Sep 20, 2024

Fixes #23315
Fixes #23321

Motivation

See #23315 and #23321. This PR fixes a bug in ConsistentHashingStickyKeyConsumerSelector where the selected consumer for a hash could change across 2 existing consumers when a consumer was removed.
In addition it fixes the problem that ConsistentHashingStickyKeyConsumerSelector.getConsumerKeyHashRanges() returned invalid information. These are fixed together since they are in the same code area and fixing getConsumerKeyHashRanges is required for testing the consistent selection of a consumer when there are hash collisions.

Modifications

Add a solution that contains a solution to distribute the selected consumer for consumers with the same name across the hash ring, but in a way where it prevents from the consumer switching across 2 existing consumers.

Documentation

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

@lhotari lhotari added this to the 4.0.0 milestone Sep 20, 2024
@lhotari lhotari self-assigned this Sep 20, 2024
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Sep 20, 2024
@lhotari lhotari marked this pull request as draft September 20, 2024 12:53
@lhotari lhotari force-pushed the lh-fix-ConsistentHashingStickyKeyConsumerSelector-select-bug branch from ac7fdeb to cc78aec Compare September 20, 2024 13:34
@lhotari lhotari marked this pull request as ready for review September 20, 2024 13:36
@lhotari lhotari changed the title [fix][broker] Fix out-of-order issue with ConsistentHashingStickyKeyConsumerSelector [fix][broker] Reduce out-of-order issues with ConsistentHashingStickyKeyConsumerSelector Sep 20, 2024
@lhotari
Copy link
Member Author

lhotari commented Sep 20, 2024

I renamed this to "reduce" out-of-order issues since I'm not sure if the current model in this PR prevents the case that a consumer gets swapped when an unrelated consumer leaves.
I was able to get the behavior fairly consistent, but it's not going to prevent all cases.

It seems that another hash ring layer is needed for the colliding consumers. That would prevent unnecessary changes. A hash ring inside a hash ring...

@lhotari lhotari marked this pull request as draft September 20, 2024 15:30
@lhotari lhotari force-pushed the lh-fix-ConsistentHashingStickyKeyConsumerSelector-select-bug branch from cc78aec to 6a1be71 Compare September 20, 2024 16:29
@lhotari lhotari marked this pull request as ready for review September 20, 2024 16:30
@lhotari lhotari marked this pull request as draft September 20, 2024 16:37
@lhotari lhotari force-pushed the lh-fix-ConsistentHashingStickyKeyConsumerSelector-select-bug branch 2 times, most recently from 04c751b to 12577d5 Compare September 20, 2024 17:31
@lhotari lhotari force-pushed the lh-fix-ConsistentHashingStickyKeyConsumerSelector-select-bug branch from b28a199 to cdf3490 Compare September 20, 2024 20:40
@lhotari lhotari force-pushed the lh-fix-ConsistentHashingStickyKeyConsumerSelector-select-bug branch from 527e431 to e5eb2ef Compare September 20, 2024 21:16
@lhotari lhotari force-pushed the lh-fix-ConsistentHashingStickyKeyConsumerSelector-select-bug branch from 06db6e3 to bae30bc Compare September 20, 2024 21:28
@lhotari lhotari changed the title [fix][broker] Reduce out-of-order issues with ConsistentHashingStickyKeyConsumerSelector [fix][broker] Fix out-of-order issues with ConsistentHashingStickyKeyConsumerSelector Sep 20, 2024
@lhotari lhotari marked this pull request as ready for review September 20, 2024 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant