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

Make sure bucket index load failure will not increase if there is context error #6054

Merged
merged 2 commits into from
Jul 3, 2024
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
10 changes: 5 additions & 5 deletions pkg/storage/tsdb/bucketindex/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -126,6 +121,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 {
alexqyle marked this conversation as resolved.
Show resolved Hide resolved
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) {
Expand Down
Loading