From 4a102381d7617ce5caf309c0edc18ba3b03f472d Mon Sep 17 00:00:00 2001 From: Aayush Shah Date: Wed, 8 Sep 2021 13:42:28 -0400 Subject: [PATCH] kvserver: improve a comment in `TransferLeaseTarget` Release justification: comments only Release note: None --- pkg/kv/kvserver/allocator.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/kv/kvserver/allocator.go b/pkg/kv/kvserver/allocator.go index 694347335798..15983dcaab7b 100644 --- a/pkg/kv/kvserver/allocator.go +++ b/pkg/kv/kvserver/allocator.go @@ -1450,8 +1450,12 @@ func (a *Allocator) TransferLeaseTarget( leaseholderReplQPS, _ := stats.avgQPS() currentDelta := getQPSDelta(storeQPSMap, existing) + // NB: If the `bestOption` ends up being the current leaseholder, then the + // check below will fail since we know that `leaseholderReplQPS` must be + // greater than 0 (the `StoreRebalancer` only bothers rebalancing leases / + // replicas for ranges serving at least some traffic). bestOption := getCandidateWithMinQPS(storeQPSMap, existing) - if bestOption != (roachpb.ReplicaDescriptor{}) && + if bestOption != (roachpb.ReplicaDescriptor{}) && leaseholderReplQPS > 0 && // It is always beneficial to transfer the lease to the coldest candidate // if the range's own qps is smaller than the difference between the // leaseholder store and the candidate store. This will always drive down