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

[query-frontend] /active_series: cancel request context when write deadline is reached #7569

Merged
merged 2 commits into from
Mar 8, 2024

Conversation

flxbk
Copy link
Contributor

@flxbk flxbk commented Mar 8, 2024

What this PR does

This is a follow-up to #7553. I realised that the request context is not cancelled when the server write deadline is reached (see e.g. here). To avoid doing unnecessary work we should cancel the request context once the deadline is reached.

This change only applies to the /active_series endpoint, the behaviour for other endpoints remains unchanged.

Which issue(s) this PR fixes or relates to

Fixes #

Checklist

  • Tests updated.
  • Documentation added.
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX].
  • about-versioning.md updated with experimental features.

@flxbk flxbk changed the title [query-frontend] cancel request context when write deadline is reached [query-frontend] /active_series: cancel request context when write deadline is reached Mar 8, 2024
@flxbk flxbk force-pushed the felix/active-series-request-timeout branch from 16c1476 to 2567674 Compare March 8, 2024 08:20
@flxbk flxbk marked this pull request as ready for review March 8, 2024 08:21
@flxbk flxbk requested a review from a team as a code owner March 8, 2024 08:21
@@ -200,6 +201,9 @@ func (f *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
writeError(w, apierror.New(apierror.TypeInternal, err.Error()))
return
}
ctx, _ := context.WithDeadlineCause(r.Context(), deadline,
cancellation.NewErrorf("write deadline exceeded (timeout: %v)", f.cfg.ActiveSeriesWriteTimeout))
Copy link
Contributor

Choose a reason for hiding this comment

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

If ActiveSeriesWriteTimeout is set to 0 (meaning to use server.http-write-timeout), this will log incorrectly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This whole block is guarded by f.cfg.ActiveSeriesWriteTimeout > 0 though, so this code will not execute if the flag is set to 0, or am I missing something? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, yes, I was looking at the previous change and didn't pay enough attention here. Thanks!

Copy link
Contributor

@jhesketh jhesketh left a comment

Choose a reason for hiding this comment

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

lgtm!

@flxbk flxbk merged commit fad05af into main Mar 8, 2024
29 checks passed
@flxbk flxbk deleted the felix/active-series-request-timeout branch March 8, 2024 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants