From 299592bf6c59fa8028dc83a1b6febeed7729b823 Mon Sep 17 00:00:00 2001 From: Alex Le Date: Tue, 2 Jul 2024 13:22:15 -0700 Subject: [PATCH 1/2] Make sure bucket index load failure will not increase if there is contenxt error Signed-off-by: Alex Le --- pkg/storage/tsdb/bucketindex/loader.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/storage/tsdb/bucketindex/loader.go b/pkg/storage/tsdb/bucketindex/loader.go index ba17d34f3e..40a29653b5 100644 --- a/pkg/storage/tsdb/bucketindex/loader.go +++ b/pkg/storage/tsdb/bucketindex/loader.go @@ -126,6 +126,11 @@ func (l *Loader) GetIndex(ctx context.Context, userID string) (*Index, Status, e // (eg. corrupted bucket index or not existing). l.cacheIndex(userID, nil, ss, err) + if ctx.Err() != nil { + level.Warn(util_log.WithContext(ctx, l.logger)).Log("msg", "received context error when reading bucket index", "err", ctx.Err()) + return nil, UnknownStatus, ctx.Err() + } + if errors.Is(err, ErrIndexNotFound) { level.Warn(l.logger).Log("msg", "bucket index not found", "user", userID) } else if errors.Is(err, bucket.ErrCustomerManagedKeyAccessDenied) { From b2ea947d39e3757fe2d011c25502869b31abd494 Mon Sep 17 00:00:00 2001 From: Alex Le Date: Tue, 2 Jul 2024 17:23:51 -0700 Subject: [PATCH 2/2] Removed duplicate code Signed-off-by: Alex Le --- pkg/storage/tsdb/bucketindex/loader.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pkg/storage/tsdb/bucketindex/loader.go b/pkg/storage/tsdb/bucketindex/loader.go index 40a29653b5..59d7121a93 100644 --- a/pkg/storage/tsdb/bucketindex/loader.go +++ b/pkg/storage/tsdb/bucketindex/loader.go @@ -93,11 +93,6 @@ func NewLoader(cfg LoaderConfig, bucketClient objstore.Bucket, cfgProvider bucke // GetIndex returns the bucket index for the given user. It returns the in-memory cached // index if available, or load it from the bucket otherwise. func (l *Loader) GetIndex(ctx context.Context, userID string) (*Index, Status, error) { - if ctx.Err() != nil { - level.Warn(util_log.WithContext(ctx, l.logger)).Log("msg", "received context error when attempting to load bucket index", "err", ctx.Err()) - return nil, UnknownStatus, ctx.Err() - } - l.indexesMx.RLock() if entry := l.indexes[userID]; entry != nil { idx := entry.index