-
Notifications
You must be signed in to change notification settings - Fork 70
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
ring: Add DoUntilQuorum method #293
Conversation
I've added an example of how this would be used to Mimir: grafana/mimir@70e788c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job, LGTM! I just left minor comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, only one comment about avoiding allocations when we don't use context tracking.
…allocations in Do that doesn't use context functionality
Still LGTM! Thanks for addressing feedback. |
This changes the forGivenIngestors function in pkg/querier/ingester_querier.go to use `DoUntilQuorum` (from [PR #293](grafana/dskit#293)) instead of `Do`. `DoUntilQuorum` is much more efficient than `Do`. The exact differences between them can be seen [here](grafana/dskit#293). --------- Co-authored-by: Trevor Whitney <[email protected]>
What this PR does:
This PR adds a
DoUntilQuorum
method to thering
package.In contrast to the existing
ReplicationSet.Do
method,DoUntilQuorum
has the following behaviour differences:DoUntilQuorum
does not support delaying invocations off
DoUntilQuorum
supports cleaning up results that will not be returned, including results that arrive afterDoUntilQuorum
returns, making it easier to ensure that resources are not leakedDoUntilQuorum
immediately cancels the context passed tof
for any invocations we know will are no longer necessary (eg. because other calls in the same zone have already failed)DoUntilQuorum
does not cancel the context passed tof
if the result is returned, which is useful for scenarios whereDoUntilQuorum
is used to establish a set of streams that will continue afterDoUntilQuorum
returnsDoUntilQuorum
only returns the minimum set of results required for quorumThis last point is best explained with an example. Imagine we have three zones each with two instances, we tolerate one unavailable zone and the results from each instance arrive in this order:
ReplicationSet.Do
would return results from all five instances, whereasDoUntilQuorum
will only return the results from the instances in zones A and B and cleanup the results from zone C, including the result from instance 2 in zone C if it arrives.Which issue(s) this PR fixes:
(none)
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]