Skip to content

Commit

Permalink
query-scheduler: replace context.Cancelled with real error (grafana#1…
Browse files Browse the repository at this point in the history
…0038)

context cancelled is less informative

Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
  • Loading branch information
dimitarvdimitrov authored and bjorns163 committed Dec 30, 2024
1 parent 673a567 commit 13b807a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/go-kit/log/level"
"github.com/grafana/dskit/cancellation"
"github.com/grafana/dskit/grpcclient"
"github.com/grafana/dskit/grpcutil"
"github.com/grafana/dskit/httpgrpc"
"github.com/grafana/dskit/middleware"
"github.com/grafana/dskit/ring"
Expand Down Expand Up @@ -508,6 +509,11 @@ func (s *Scheduler) forwardRequestToQuerier(querier schedulerpb.SchedulerForQuer
QueueTimeNanos: queueTime.Nanoseconds(),
})

if grpcutil.IsCanceled(err) {
// The querier abruptly closing the connection should be the only reason we'd get a cancellation error here.
err = fmt.Errorf("querier disconnected ungracefully")
}

if err != nil {
errCh <- fmt.Errorf("failed to send query to querier '%v': %w", querierID, err)
span.LogFields(otlog.Message("sending query to querier failed"), otlog.Error(err))
Expand All @@ -519,6 +525,12 @@ func (s *Scheduler) forwardRequestToQuerier(querier schedulerpb.SchedulerForQuer
span.Finish()

_, err = querier.Recv()

if grpcutil.IsCanceled(err) {
// The querier abruptly closing the connection should be the only reason we'd get a cancellation error here.
err = fmt.Errorf("querier disconnected ungracefully")
}

if err != nil {
errCh <- fmt.Errorf("failed to receive response from querier '%v': %w", querierID, err)
return
Expand Down

0 comments on commit 13b807a

Please sign in to comment.