MCPcopy Create free account
hub / github.com/cortexproject/cortex / compactUserWithRetries

Method compactUserWithRetries

pkg/compactor/compactor.go:957–995  ·  view source on GitHub ↗
(ctx context.Context, userID string)

Source from the content-addressed store, hash-verified

955}
956
957func (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
997func (c *Compactor) compactUser(ctx context.Context, userID string) error {
998 bucket := bucket.NewUserBucketClient(userID, c.bucketClient, c.limits)

Callers 1

compactUsersMethod · 0.95

Calls 12

compactUserMethod · 0.95
NewFunction · 0.92
OngoingMethod · 0.80
CauseMethod · 0.80
ErrMethod · 0.65
LogMethod · 0.45
IncMethod · 0.45
ErrorMethod · 0.45
WaitMethod · 0.45
UnwrapMethod · 0.45
IsMethod · 0.45

Tested by

no test coverage detected