(ctx context.Context, userID string)
| 955 | } |
| 956 | |
| 957 | func (c *Compactor) compactUserWithRetries(ctx context.Context, userID string) error { |
| 958 | var lastErr error |
| 959 | |
| 960 | retries := backoff.New(ctx, backoff.Config{ |
| 961 | MinBackoff: c.compactorCfg.retryMinBackoff, |
| 962 | MaxBackoff: c.compactorCfg.retryMaxBackoff, |
| 963 | MaxRetries: c.compactorCfg.CompactionRetries, |
| 964 | }) |
| 965 | |
| 966 | for retries.Ongoing() { |
| 967 | lastErr = c.compactUser(ctx, userID) |
| 968 | if lastErr == nil { |
| 969 | return nil |
| 970 | } |
| 971 | if ctx.Err() != nil { |
| 972 | return ctx.Err() |
| 973 | } |
| 974 | if c.isCausedByPermissionDenied(lastErr) { |
| 975 | level.Warn(c.logger).Log("msg", "skipping compactUser due to PermissionDenied", "user", userID, "err", lastErr) |
| 976 | c.compactorMetrics.compactionErrorsCount.WithLabelValues(userID, unauthorizedError).Inc() |
| 977 | return nil |
| 978 | } |
| 979 | if compact.IsHaltError(lastErr) { |
| 980 | level.Error(c.logger).Log("msg", "compactor returned critical error", "user", userID, "err", lastErr) |
| 981 | c.compactorMetrics.compactionErrorsCount.WithLabelValues(userID, haltError).Inc() |
| 982 | return lastErr |
| 983 | } |
| 984 | c.compactorMetrics.compactionErrorsCount.WithLabelValues(userID, retriableError).Inc() |
| 985 | |
| 986 | retries.Wait() |
| 987 | } |
| 988 | |
| 989 | err := errors.Unwrap(errors.Cause(lastErr)) |
| 990 | if errors.Is(err, plannerCompletedPartitionError) || errors.Is(err, plannerVisitedPartitionError) { |
| 991 | return nil |
| 992 | } |
| 993 | |
| 994 | return lastErr |
| 995 | } |
| 996 | |
| 997 | func (c *Compactor) compactUser(ctx context.Context, userID string) error { |
| 998 | bucket := bucket.NewUserBucketClient(userID, c.bucketClient, c.limits) |
no test coverage detected