Skip to content

kvserver: allow VOTER_INCOMING to receive the lease#74546

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
shralex:remove_leaseholder_step3
Jan 7, 2022
Merged

kvserver: allow VOTER_INCOMING to receive the lease#74546
craig[bot] merged 1 commit intocockroachdb:masterfrom
shralex:remove_leaseholder_step3

Conversation

@shralex
Copy link
Copy Markdown
Contributor

@shralex shralex commented Jan 6, 2022

Previously, VOTER_INCOMING replicas joining the cluster weren't allowed
to receive the lease, even though there is no actual problem with doing so.
This change removes the restriction, as a step towards #74077

Release note: None

Previously, VOTER_INCOMING replicas joining the cluster weren't allowed
to receive the lease, even though there is no actual problem with doing so.
This change removes the restriction, as a step towards cockroachdb#74077

Release note: None
@shralex shralex requested review from aayushshah15 and nvb January 6, 2022 20:06
@shralex shralex requested a review from a team as a code owner January 6, 2022 20:06
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Contributor

@nvb nvb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 3 of 3 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @aayushshah15)

@shralex
Copy link
Copy Markdown
Contributor Author

shralex commented Jan 6, 2022

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jan 7, 2022

Build succeeded:

@craig craig bot merged commit 2ffb8b2 into cockroachdb:master Jan 7, 2022
craig bot pushed a commit that referenced this pull request Jul 29, 2022
85140: kvserver: ignore leaseholder replica type in DistSender r=arulajmani a=erikgrinaker

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 to
compare the new leaseholder replica descriptor with the one in its range
descriptor. There are two reasons why this can happen:

1. `ReplicaDescriptor.ReplicaType` is a pointer, where the zero-value
   `nil` is equivalent to `VOTER`. The equality comparison used in
   `MoveToFront()` is `==`, but pointer equality compares the memory
   address rather than the value.

2. 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` replica
   type.

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 during
query execution, leading to occasional increased tail latencies due
to unnecessary internal retries.

Co-authored-by: Erik Grinaker <grinaker@cockroachlabs.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants