Skip to content

Commit 9ab3dc0

Browse files
committed
kvserver: guard inversion check and requeue behind PriorityInversionRequeue
Previously, we introduced the PriorityInversionRequeue cluster setting, intended for backport, to handle cases where a range was enqueued with a high-priority repair action but, at processing time, a low-priority rebalance action was computed. In such cases, the caller re-adds the range to the queue under its updated priority. Although the cluster setting guards this requeue behavior, the inversion check always ran unconditionally, reducing backport safety. This commit updates the logic so that the cluster setting guard both the inversion check and the requeue behavior.
1 parent 5140a28 commit 9ab3dc0

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

pkg/kv/kvserver/replicate_queue.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -926,21 +926,21 @@ func (rq *replicateQueue) processOneChange(
926926
change, err := rq.planner.PlanOneChange(
927927
ctx, repl, desc, conf, plan.PlannerOptions{Scatter: scatter})
928928

929-
inversion, shouldRequeue := allocatorimpl.CheckPriorityInversion(priorityAtEnqueue, change.Action)
930-
if inversion {
931-
if priorityInversionLogEveryN.ShouldLog() {
932-
log.KvDistribution.Infof(ctx,
933-
"priority inversion during process: shouldRequeue = %t action=%s, priority=%v, enqueuePriority=%v",
934-
shouldRequeue, change.Action, change.Action.Priority(), priorityAtEnqueue)
935-
}
936-
937-
if shouldRequeue && PriorityInversionRequeue.Get(&rq.store.cfg.Settings.SV) {
938-
// Return true to requeue the range. Return the error to ensure it is
939-
// logged and tracked in replicate queue bq.failures metrics. See
940-
// replicateQueue.process for details.
941-
return true /*requeue*/, maybeAnnotateDecommissionErr(
942-
errors.Errorf("requing due to priority inversion: action=%s, priority=%v, enqueuePriority=%v",
943-
change.Action, change.Action.Priority(), priorityAtEnqueue), change.Action)
929+
if PriorityInversionRequeue.Get(&rq.store.cfg.Settings.SV) {
930+
if inversion, shouldRequeue := allocatorimpl.CheckPriorityInversion(priorityAtEnqueue, change.Action); inversion {
931+
if priorityInversionLogEveryN.ShouldLog() {
932+
log.KvDistribution.Infof(ctx,
933+
"priority inversion during process: shouldRequeue = %t action=%s, priority=%v, enqueuePriority=%v",
934+
shouldRequeue, change.Action, change.Action.Priority(), priorityAtEnqueue)
935+
}
936+
if shouldRequeue {
937+
// Return true to requeue the range. Return the error to ensure it is
938+
// logged and tracked in replicate queue bq.failures metrics. See
939+
// replicateQueue.process for details.
940+
return true /*requeue*/, maybeAnnotateDecommissionErr(
941+
errors.Errorf("requing due to priority inversion: action=%s, priority=%v, enqueuePriority=%v",
942+
change.Action, change.Action.Priority(), priorityAtEnqueue), change.Action)
943+
}
944944
}
945945
}
946946

0 commit comments

Comments
 (0)