release-22.1: kvserver: ignore leaseholder replica type in DistSender #85315
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport 1/1 commits from #85140.
/cc @cockroachdb/release
Release justification: fixes a latency regression in 22.1.
The DistSender could fail to prioritize a newly discovered leaseholder
from a
NotLeaseHolderError
if the leaseholder had a non-VOTER
replica type. Instead, it would continue to try replicas in order until
possibly exhausting the transport and backing off, leading to increased
tail latencies. This applies in particular to 22.1, where we allowed
VOTER_INCOMING
replicas to acquire the lease (see 22b4fb5).The primary reason is that
grpcTransport.MoveToFront()
would fail tocompare the new leaseholder replica descriptor with the one in its range
descriptor. There are two reasons why this can happen:
ReplicaDescriptor.ReplicaType
is a pointer, where the zero-valuenil
is equivalent toVOTER
. The equality comparison used inMoveToFront()
is==
, but pointer equality compares the memoryaddress rather than the value.
The transport will keep using the initial range descriptor when it
was created, and not updating it as we receive updated range
descriptors. This means that the transport may e.g. have a
nil
replica type while the leaseholder has an
VOTER_INCOMING
replicatype.
This patch fixes both issues by adding
ReplicaDescriptor.IsSame()
which compares replica identities while ignoring the type.
Resolves #85060.
Touches #74546.
Release note (bug fix): Fixed a bug where new leaseholders (with a
VOTER_INCOMING
type) would not always be detected properly duringquery execution, leading to occasional increased tail latencies due
to unnecessary internal retries.