Skip to content

Commit b632b95

Browse files
committed
kvserver: check for requeue before error checking in rq.process
Previously, we checked for requeue right before returning for both nil and non-nil errors, making the code harder to follow. This commit refactors replicateQueue.process to requeue replicas before checking for errors.
1 parent 8e9e4c1 commit b632b95

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

pkg/kv/kvserver/replicate_queue.go

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -721,25 +721,21 @@ func (rq *replicateQueue) process(
721721
log.KvDistribution.Infof(ctx, "%v", err)
722722
continue
723723
}
724-
724+
// At the time of writing, requeue => err == nil except for priority
725+
// inversions. Priority inversion intentionally returns a priority inversion
726+
// error along with requeue = true.
727+
if requeue {
728+
log.KvDistribution.VEventf(ctx, 1, "re-queuing: %v", err)
729+
rq.maybeAdd(ctx, repl, rq.store.Clock().NowAsClockTimestamp())
730+
}
725731
if err != nil {
726-
if requeue {
727-
log.KvDistribution.VEventf(ctx, 1, "re-queuing on errors: %v", err)
728-
rq.maybeAdd(ctx, repl, rq.store.Clock().NowAsClockTimestamp())
729-
}
730732
return false, err
731733
}
732-
733734
if testingAggressiveConsistencyChecks {
734735
if _, err := rq.store.consistencyQueue.process(ctx, repl, confReader, -1 /*priorityAtEnqueue*/); err != nil {
735736
log.KvDistribution.Warningf(ctx, "%v", err)
736737
}
737738
}
738-
739-
if requeue {
740-
log.KvDistribution.VEventf(ctx, 1, "re-queuing")
741-
rq.maybeAdd(ctx, repl, rq.store.Clock().NowAsClockTimestamp())
742-
}
743739
return true, nil
744740
}
745741

0 commit comments

Comments
 (0)