cockroach icon indicating copy to clipboard operation
cockroach copied to clipboard

kvserver: read lease under mutex when switching lease type

Open kvoli opened this issue 1 year ago • 2 comments

A race could occur when a replica queue and post lease application both attempted to switch the lease type. This race would cause the queue to not process the replica because the lease type had already changed. As a result, lease preference violations might not have been quickly resolved by the lease queue.

Read the lease under the same mutex used for requesting the lease, when possibly switching the lease type.

Resolves: #123998 Release note: None

kvoli avatar May 15 '24 15:05 kvoli

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

:owl: Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

blathers-crl[bot] avatar May 15 '24 15:05 blathers-crl[bot]

This change is Reviewable

cockroach-teamcity avatar May 15 '24 15:05 cockroach-teamcity

This passes 10/10 tests for lease-preferences/manual-violating-transfer. Previously, it would fail 1/3 of the time.

kvoli avatar May 16 '24 13:05 kvoli

bors r=nvanbenschoten

kvoli avatar May 17 '24 14:05 kvoli