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: do not log error if context is canceled #4562

Merged
merged 3 commits into from
Dec 2, 2021

Conversation

GiedriusS
Copy link
Contributor

@GiedriusS GiedriusS commented Nov 23, 2021

What this PR does:

My Thanos instance is spamming this whenever the user cancels a query
that is being executed:

{"caller":"retry.go:73","err":"context canceled","level":"error","msg":"error processing request","org_id":"anonymous","try":0,"ts":"2021-11-23T13:35:09.275914072Z"}

It doesn't mean anything bad so let's stop the spam. Thus, do not perform the
retrying logic if the context has been canceled. Later on this is handled in:

	resp, err := f.roundTripper.RoundTrip(r)
	queryResponseTime := time.Since(startTime)

	if err != nil {
		writeError(w, err)
		return
	}

Which issue(s) this PR fixes:
N/A

Checklist

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

My Thanos instance is spamming this whenever the user cancels a query
that is being executed:

```
{"caller":"retry.go:73","err":"context canceled","level":"error","msg":"error processing request","org_id":"anonymous","try":0,"ts":"2021-11-23T13:35:09.275914072Z"}
```

It doesn't mean anything bad so let's stop the spam. Thus, do not perform the
retrying logic if the context has been canceled. Later on this is handled in:

```go
	resp, err := f.roundTripper.RoundTrip(r)
	queryResponseTime := time.Since(startTime)

	if err != nil {
		writeError(w, err)
		return
	}
```

Signed-off-by: Giedrius Statkevičius <[email protected]>
Signed-off-by: Giedrius Statkevičius <[email protected]>
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.

Thank you.

@GiedriusS
Copy link
Contributor Author

Unit tests pass locally just fine, I assume it's the same with integration tests (panic: test timed out after 40m0s).

@bboreham
Copy link
Contributor

I believe this line means it did not retry:

if ctx.Err() != nil {
return nil, ctx.Err()

However I agree with you about not logging a cancellation as an error.

I might prefer to have the same if-condition in both cases, rather than introducing the new errors.Is. What do you think?

@bboreham bboreham merged commit b525af5 into cortexproject:master Dec 2, 2021
@bboreham bboreham changed the title queryrange: retry: do not retry if context is canceled query-frontend: do not log error if context is canceled Dec 2, 2021
@GiedriusS
Copy link
Contributor Author

Sorry, I was a bit busy. I can change it if you want to 👍

alvinlin123 pushed a commit to ac1214/cortex that referenced this pull request Jan 14, 2022
…#4562)

* query-frontend: do not log error if context is canceled

Example whenever the user cancels a query that is being executed:

```
{"caller":"retry.go:73","err":"context canceled","level":"error","msg":"error processing request","org_id":"anonymous","try":0,"ts":"2021-11-23T13:35:09.275914072Z"}
```

It doesn't mean anything bad so let's stop the spam. 

Signed-off-by: Giedrius Statkevičius <[email protected]>
Signed-off-by: Alvin Lin <[email protected]>
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