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

receive: fail early if ketama hashring is configured with number of nodes lower than the replication factor #6168

Merged

Conversation

MichaHoffmann
Copy link
Contributor

@MichaHoffmann MichaHoffmann commented Feb 27, 2023

Addresses #5639

  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

Changes

Construction of the ketama hashring can busyloop forever if less endpoints than replication factor was configured even briefly.

Verification

Added a unittest.

Copy link
Collaborator

@matej-g matej-g left a comment

Choose a reason for hiding this comment

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

Thanks @MichaHoffmann, this is looking nice!

I'm not sure why CircleCI is on strike again, I often see the run fails for first-time contributors, I'll try to see if we can fix it.

pkg/receive/hashring.go Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@MichaHoffmann MichaHoffmann force-pushed the mhoffm-fail-ketama-hashring-early branch from 5bb16dc to 3f4491d Compare February 27, 2023 16:56
@MichaHoffmann MichaHoffmann changed the title receive: fail early if ketama hashring is ill-configured receive: fail early if ketama hashring is configured with number of nodes lower than the replication factor Feb 27, 2023
Copy link
Contributor

@fpetkovski fpetkovski left a comment

Choose a reason for hiding this comment

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

Thanks, looks good overall. Just some small nits about errors and assertions.

@@ -576,7 +579,10 @@ func testReceiveQuorum(t *testing.T, hashringAlgo HashringAlgorithm, withConsist
},
} {
t.Run(tc.name, func(t *testing.T) {
handlers, hashring := newTestHandlerHashring(tc.appendables, tc.replicationFactor, hashringAlgo)
handlers, hashring, err := newTestHandlerHashring(tc.appendables, tc.replicationFactor, hashringAlgo)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

We usually use testutil.Ok.

Copy link
Contributor

Choose a reason for hiding this comment

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

I chose that to be consistent with the other assertions in this test. Its probably best to update all of them. While i'm at it should i also convert them to testutil.Ok form?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that's a good point, let's then leave it as it is for consistency.

pkg/receive/hashring.go Outdated Show resolved Hide resolved
@MichaHoffmann MichaHoffmann force-pushed the mhoffm-fail-ketama-hashring-early branch from a079830 to 36740b6 Compare February 28, 2023 17:24
Signed-off-by: Michael Hoffmann <mhoffm@posteo.de>
@MichaHoffmann MichaHoffmann force-pushed the mhoffm-fail-ketama-hashring-early branch from 7fbb9f6 to 75cc464 Compare February 28, 2023 17:27
Copy link
Collaborator

@matej-g matej-g left a comment

Choose a reason for hiding this comment

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

Nice work @MichaHoffmann 💪

Copy link
Contributor

@fpetkovski fpetkovski left a comment

Choose a reason for hiding this comment

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

Thanks!

@fpetkovski fpetkovski merged commit 2450b61 into thanos-io:main Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants