Skip to content

Commit 3652f9e

Browse files
committed
queryrange: retry: do not retry if context is canceled
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]>
1 parent ca39b4c commit 3652f9e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pkg/querier/queryrange/retry.go

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package queryrange
22

33
import (
44
"context"
5+
"errors"
56

67
"github.com/go-kit/log"
78
"github.com/go-kit/log/level"
@@ -66,6 +67,10 @@ func (r retry) Do(ctx context.Context, req Request) (Response, error) {
6667
return resp, nil
6768
}
6869

70+
if errors.Is(err, context.Canceled) {
71+
return nil, err
72+
}
73+
6974
// Retry if we get a HTTP 500 or a non-HTTP error.
7075
httpResp, ok := httpgrpc.HTTPResponseFromError(err)
7176
if !ok || httpResp.Code/100 == 5 {

0 commit comments

Comments
 (0)