Skip to content

Cancel abandoned operations in ReplicationSet.Do() #3178

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

Merged
merged 2 commits into from
Sep 17, 2020
Merged

Conversation

bboreham
Copy link
Contributor

Generally it will start a set of operations in parallel, and return once enough of them have succeeded. Pass down a context to each one, and cancel that context when ReplicationSet.Do() returns.

Fixes #3169

Checklist

  • NA Tests updated
  • NA Documentation added
  • CHANGELOG.md updated

Generally it will start a set of operations in parallel, and return
once enough of them have succeeded. Pass down a context to each one,
and cancel that context when ReplicationSet.Do() returns.

Signed-off-by: Bryan Boreham <[email protected]>
Copy link
Contributor

@pracucci pracucci left a comment

Choose a reason for hiding this comment

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

Makes sense to me, and applies only to the read path (we can't do the same for the write path, but isn't touched).

@bboreham
Copy link
Contributor Author

we can't do the same for the write path, but isn't touched

Note the top-level context does get canceled when the request returns at top level, so the write path takes precautions to avoid being impacted by that:

// Use a background context to make sure all ingesters get samples even if we return early
localCtx, cancel := context.WithTimeout(context.Background(), d.cfg.RemoteTimeout)

The reason why I wanted this PR in the read path is that requests in the querier can run for a while after ingester requests, e.g. evaluating PromQL over the data.

@@ -76,6 +76,7 @@
* [BUGFIX] Configs: prevent validation of templates to fail when using template functions. #3157
* [BUGFIX] Configuring the S3 URL with an `@` but without username and password doesn't enable the AWS static credentials anymore. #3170
* [BUGFIX] Limit errors on ranged queries (`api/v1/query_range`) no longer return a status code `500` but `422` instead. #3167
* [BUGFIX] No-longer-needed ingester operations from queries are now canceled. #3178
Copy link
Contributor

Choose a reason for hiding this comment

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

I've just merged a PR to cut the CHANGELOG because of the upcoming 1.4.0 release. Could you rebase master and move your CHANGELOG entry to the top, under ## master / unreleased, please?

@pracucci pracucci requested a review from pstibrany September 16, 2020 06:55
Copy link
Contributor

@pstibrany pstibrany left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@@ -76,6 +76,7 @@
* [BUGFIX] Configs: prevent validation of templates to fail when using template functions. #3157
* [BUGFIX] Configuring the S3 URL with an `@` but without username and password doesn't enable the AWS static credentials anymore. #3170
* [BUGFIX] Limit errors on ranged queries (`api/v1/query_range`) no longer return a status code `500` but `422` instead. #3167
* [BUGFIX] No-longer-needed ingester operations from queries are now canceled. #3178
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo in queriers.

Copy link
Contributor

Choose a reason for hiding this comment

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

I left the same comment, but Bryan correctly told it's intended to be "queries" because it affects both queriers and rulers.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, it confused two of us, so perhaps better wording like "operations caused by queries" would improve it?

@pracucci pracucci merged commit c9d4394 into master Sep 17, 2020
@pracucci pracucci deleted the cancel-rs-do branch September 17, 2020 10:04
@pracucci pracucci mentioned this pull request Sep 17, 2020
3 tasks
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.

Abandoned QueryStream calls to ingesters should get canceled
3 participants