Skip to content

Commit ca308b0

Browse files
authored
add context check when decoding cached postings (#6506)
Signed-off-by: Ben Ye <[email protected]>
1 parent c6623f8 commit ca308b0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pkg/store/bucket.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2457,13 +2457,13 @@ func (r *bucketIndexReader) fetchExpandedPostingsFromCache(ctx context.Context,
24572457
}()
24582458
// If failed to decode or expand cached postings, return and expand postings again.
24592459
if err != nil {
2460-
level.Error(r.block.logger).Log("msg", "failed to decode cached expanded postings, refetch postings", "id", r.block.meta.ULID.String())
2460+
level.Error(r.block.logger).Log("msg", "failed to decode cached expanded postings, refetch postings", "id", r.block.meta.ULID.String(), "err", err)
24612461
return false, nil, nil
24622462
}
24632463

24642464
ps, err := ExpandPostingsWithContext(ctx, p)
24652465
if err != nil {
2466-
level.Error(r.block.logger).Log("msg", "failed to expand cached expanded postings, refetch postings", "id", r.block.meta.ULID.String())
2466+
level.Error(r.block.logger).Log("msg", "failed to expand cached expanded postings, refetch postings", "id", r.block.meta.ULID.String(), "err", err)
24672467
return false, nil, nil
24682468
}
24692469

@@ -2527,6 +2527,9 @@ func (r *bucketIndexReader) fetchPostings(ctx context.Context, keys []labels.Lab
25272527
// If we have a miss, mark key to be fetched in `ptrs` slice.
25282528
// Overlaps are well handled by partitioner, so we don't need to deduplicate keys.
25292529
for ix, key := range keys {
2530+
if err := ctx.Err(); err != nil {
2531+
return nil, closeFns, err
2532+
}
25302533
// Get postings for the given key from cache first.
25312534
if b, ok := fromCache[key]; ok {
25322535
r.stats.postingsTouched++

0 commit comments

Comments
 (0)