Skip to content

Commit 5384364

Browse files
committed
kvserver: use priorityInversionLogEveryN
Previously, replicateQueue used V(2) to log info on priority inverted replicas because I wanted visibility into every case without missing any replicas. On reflection, the individual cases aren’t that interesting - it’s the overall volume that matters, which we can track through metrics. This commit changes it so that we just rate limit priority inversions every 3 seconds.
1 parent 4acb38f commit 5384364

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

pkg/kv/kvserver/replicate_queue.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,10 @@ func ShouldRequeue(
910910
return requeue
911911
}
912912

913+
// priorityInversionLogEveryN rate limits how often we log about priority
914+
// inversion to avoid spams.
915+
var priorityInversionLogEveryN = log.Every(3 * time.Second)
916+
913917
func (rq *replicateQueue) processOneChange(
914918
ctx context.Context,
915919
repl *Replica,
@@ -923,9 +927,12 @@ func (rq *replicateQueue) processOneChange(
923927

924928
inversion, shouldRequeue := allocatorimpl.CheckPriorityInversion(priorityAtEnqueue, change.Action)
925929
if inversion {
926-
log.KvDistribution.VInfof(ctx, 2,
927-
"priority inversion during process: shouldRequeue = %t action=%s, priority=%v, enqueuePriority=%v",
928-
shouldRequeue, change.Action, change.Action.Priority(), priorityAtEnqueue)
930+
if priorityInversionLogEveryN.ShouldLog() {
931+
log.KvDistribution.Infof(ctx,
932+
"priority inversion during process: shouldRequeue = %t action=%s, priority=%v, enqueuePriority=%v",
933+
shouldRequeue, change.Action, change.Action.Priority(), priorityAtEnqueue)
934+
}
935+
929936
if shouldRequeue && PriorityInversionRequeue.Get(&rq.store.cfg.Settings.SV) {
930937
// Return true here to requeue the range. We can't return an error here
931938
// because rq.process only requeue when error is nil. See

0 commit comments

Comments
 (0)