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

store-gateway: wait for query gate after loading blocks #5507

Merged
merged 3 commits into from
Jul 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions pkg/storegateway/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,17 +562,6 @@ func (s *BucketStore) Series(req *storepb.SeriesRequest, srv storepb.Store_Serie
err = status.Error(code, err.Error())
}()

if s.queryGate != nil {
tracing.DoWithSpan(srv.Context(), "store_query_gate_ismyturn", func(ctx context.Context, _ tracing.Span) {
err = s.queryGate.Start(srv.Context())
})
if err != nil {
return errors.Wrapf(err, "failed to wait for turn")
}

defer s.queryGate.Done()
}

matchers, err := storepb.MatchersToPromMatchers(req.Matchers...)
if err != nil {
return status.Error(codes.InvalidArgument, err.Error())
Expand Down Expand Up @@ -620,6 +609,16 @@ func (s *BucketStore) Series(req *storepb.SeriesRequest, srv storepb.Store_Serie
readers = newChunkReaders(chunkReaders)
}

// Wait for the query gate only after opening blocks. Opening blocks is usually fast (~1ms),
// but sometimes it can take minutes if the block isn't loaded and there is a surge in queries for unloaded blocks.
tracing.DoWithSpan(ctx, "store_query_gate_ismyturn", func(ctx context.Context, _ tracing.Span) {
err = s.queryGate.Start(ctx)
})
if err != nil {
return errors.Wrapf(err, "failed to wait for turn")
}
defer s.queryGate.Done()

var (
// If we are streaming the series labels and chunks separately, we don't need to fetch the postings
// twice. So we use these slices to re-use them. Each reuse[i] corresponds to a single block.
Expand Down
Loading