Skip to content

Commit

Permalink
Fix: Failure to close BlockSeriesClient cause store-gateway deadlock
Browse files Browse the repository at this point in the history
Signed-off-by: Alan Protasio <[email protected]>
  • Loading branch information
alanprot committed Jan 30, 2023
1 parent 48e2806 commit ff5e065
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions pkg/store/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -1226,21 +1226,22 @@ func (s *BucketStore) Series(req *storepb.SeriesRequest, srv storepb.Store_Serie
}

shardMatcher := req.ShardInfo.Matcher(&s.buffers)
blockClient := newBlockSeriesClient(
srv.Context(),
s.logger,
blk,
req,
chunksLimiter,
bytesLimiter,
shardMatcher,
s.enableChunkHashCalculation,
s.seriesBatchSize,
s.metrics.chunkFetchDuration,
)
defer blockClient.Close()

g.Go(func() error {
blockClient := newBlockSeriesClient(
srv.Context(),
s.logger,
blk,
req,
chunksLimiter,
bytesLimiter,
shardMatcher,
s.enableChunkHashCalculation,
s.seriesBatchSize,
s.metrics.chunkFetchDuration,
)
defer blockClient.Close()

span, _ := tracing.StartSpan(gctx, "bucket_store_block_series", tracing.Tags{
"block.id": blk.meta.ULID,
"block.mint": blk.meta.MinTime,
Expand Down Expand Up @@ -1482,6 +1483,7 @@ func (s *BucketStore) LabelNames(ctx context.Context, req *storepb.LabelNamesReq
SkipChunks: true,
}
blockClient := newBlockSeriesClient(newCtx, s.logger, b, seriesReq, nil, bytesLimiter, nil, true, SeriesBatchSize, s.metrics.chunkFetchDuration)
defer blockClient.Close()

if err := blockClient.ExpandPostings(
reqSeriesMatchersNoExtLabels,
Expand Down Expand Up @@ -1656,6 +1658,7 @@ func (s *BucketStore) LabelValues(ctx context.Context, req *storepb.LabelValuesR
SkipChunks: true,
}
blockClient := newBlockSeriesClient(newCtx, s.logger, b, seriesReq, nil, bytesLimiter, nil, true, SeriesBatchSize, s.metrics.chunkFetchDuration)
defer blockClient.Close()

if err := blockClient.ExpandPostings(
reqSeriesMatchersNoExtLabels,
Expand Down

0 comments on commit ff5e065

Please sign in to comment.