Skip to content

Commit 14dc2c6

Browse files
authored
Make sure bucket index load failure will not increase if there is context error (#6054)
* Make sure bucket index load failure will not increase if there is contenxt error Signed-off-by: Alex Le <[email protected]> * Removed duplicate code Signed-off-by: Alex Le <[email protected]> --------- Signed-off-by: Alex Le <[email protected]>
1 parent 18e5fb3 commit 14dc2c6

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Diff for: pkg/storage/tsdb/bucketindex/loader.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,6 @@ func NewLoader(cfg LoaderConfig, bucketClient objstore.Bucket, cfgProvider bucke
9393
// GetIndex returns the bucket index for the given user. It returns the in-memory cached
9494
// index if available, or load it from the bucket otherwise.
9595
func (l *Loader) GetIndex(ctx context.Context, userID string) (*Index, Status, error) {
96-
if ctx.Err() != nil {
97-
level.Warn(util_log.WithContext(ctx, l.logger)).Log("msg", "received context error when attempting to load bucket index", "err", ctx.Err())
98-
return nil, UnknownStatus, ctx.Err()
99-
}
100-
10196
l.indexesMx.RLock()
10297
if entry := l.indexes[userID]; entry != nil {
10398
idx := entry.index
@@ -126,6 +121,11 @@ func (l *Loader) GetIndex(ctx context.Context, userID string) (*Index, Status, e
126121
// (eg. corrupted bucket index or not existing).
127122
l.cacheIndex(userID, nil, ss, err)
128123

124+
if ctx.Err() != nil {
125+
level.Warn(util_log.WithContext(ctx, l.logger)).Log("msg", "received context error when reading bucket index", "err", ctx.Err())
126+
return nil, UnknownStatus, ctx.Err()
127+
}
128+
129129
if errors.Is(err, ErrIndexNotFound) {
130130
level.Warn(l.logger).Log("msg", "bucket index not found", "user", userID)
131131
} else if errors.Is(err, bucket.ErrCustomerManagedKeyAccessDenied) {

0 commit comments

Comments
 (0)