Skip to content
Draft
Show file tree
Hide file tree
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
13 changes: 10 additions & 3 deletions pkg/kv/kvserver/allocator/allocatorimpl/allocator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,12 @@ func (s *GoodCandidateSelector) selectOne(cl candidateList) *candidate {
return cl.selectGood(s.randGen)
}

// ErrThrottledStores is returned when no suitable stores can be found, and
// there are throttled stores. Store throttling is typically transient, so these
// errors should be retried with appropriate backoff. It is currently retried by
// the decommissioning pre-check.
var ErrThrottledStores = errors.New("some stores are currently throttled")

// AllocateTarget returns a suitable store for a new allocation of a voting or
// non-voting replica with the required attributes. Nodes already accommodating
// voting replicas are ruled out in the voter case, and nodes accommodating
Expand Down Expand Up @@ -1365,10 +1371,11 @@ func (a *Allocator) AllocateTarget(
}

// When there are throttled stores that do match, we shouldn't send
// the replica to purgatory.
// the replica to purgatory. For decommissioning pre-checks, we return a
// retryable error since throttling is transient.
if len(throttled) > 0 {
return roachpb.ReplicationTarget{}, "", errors.Errorf(
"%d matching stores are currently throttled: %v", len(throttled), throttled,
return roachpb.ReplicationTarget{}, "", errors.Wrapf(
ErrThrottledStores, "stores=%v", throttled,
)
}

Expand Down
7 changes: 7 additions & 0 deletions pkg/server/decommission.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,16 @@ func (s *topLevelServer) DecommissionPreCheck(
}
for r := retry.StartWithCtx(ctx, retryOpts); r.Next(); {
action, _, recording, rErr = evalStore.AllocatorCheckRange(ctx, &desc, collectTraces, overrideStorePool)
// If there is no error, we're done.
if rErr == nil {
break
}
// If the error is not due to store throttling, don't retry.
if !errors.Is(rErr, allocatorimpl.ErrThrottledStores) {
log.KvDistribution.Infof(ctx, "allocator found error for r%d, not retrying: %v", desc.RangeID, rErr)
break
}
// Otherwise, error is due to throttled stores, retry.
}
rangesChecked += 1
actionCounts[action.String()] += 1
Expand Down
Loading