Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kv: fix lock promotion state mismatch in tryFreeLockOnReplicatedAcquire #122009

Merged
merged 1 commit into from
Apr 9, 2024

Conversation

arulajmani
Copy link
Collaborator

Previously, when a lock was free-ed on replicated re-acquisition, we woudln't release any locking requests from the lock holder's transaction. Now, if the re-acquisition corresponded to a lock promotion, we would leave the lock's wait queue in mismatched state -- the request that acquired the replicated lock would think it's promoting, but we just released the lock.

This mismatched state was short lived (and thus benign), as the lock acquisition was quickly followed by a call to Dequeue that would do the right thing. However, this would have prevented us from making verification claims around lock promoters (see #120909), so it's worth addressing.

Informs #120909

Release note: None

@arulajmani arulajmani added the backport-24.1.x Flags PRs that need to be backported to 24.1. label Apr 9, 2024
@arulajmani arulajmani requested a review from a team as a code owner April 9, 2024 13:52
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Member

@nvanbenschoten nvanbenschoten 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 2 of 2 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @arulajmani)


pkg/kv/kvserver/concurrency/testdata/lock_table/lock_promotion line 50 at r1 (raw file):

    active: false req: 2 promoting: true, strength: Intent, txn: 00000000-0000-0000-0000-000000000001

# Replicated lock acquisition will cause us to forget the unreplicated lock.

nit: update this comment?


pkg/kv/kvserver/concurrency/testdata/lock_table/lock_promotion line 58 at r1 (raw file):

    active: false req: 2 promoting: true, strength: Intent, txn: 00000000-0000-0000-0000-000000000001

dequeue r=req2

nit: should we keep the (no-op) dequeue to make this behave like it will in practice?

Previously, when a lock was free-ed on replicated re-acquisition, we
woudln't release any locking requests from the lock holder's
transaction. Now, if the re-acquisition corresponded to a lock
promotion, we would leave the lock's wait queue in mismatched state --
the request that acquired the replicated lock would think it's
promoting, but we just released the lock.

This mismatched state was short lived (and thus benign), as the lock
acquisition was quickly followed by a call to `Dequeue` that would do
the right thing. However, this would have prevented us from making
verification claims around lock promoters (see cockroachdb#120909), so it's worth
addressing.

Informs cockroachdb#120909

Release note: None
Copy link
Collaborator Author

@arulajmani arulajmani left a comment

Choose a reason for hiding this comment

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

TFTR!

bors r=nvanbenschoten

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @nvanbenschoten)


pkg/kv/kvserver/concurrency/testdata/lock_table/lock_promotion line 50 at r1 (raw file):

Previously, nvanbenschoten (Nathan VanBenschoten) wrote…

nit: update this comment?

I assume you were hinting towards clarification about what happens to the inactive waiter in the lock's wait queue? If so, done.


pkg/kv/kvserver/concurrency/testdata/lock_table/lock_promotion line 58 at r1 (raw file):

Previously, nvanbenschoten (Nathan VanBenschoten) wrote…

nit: should we keep the (no-op) dequeue to make this behave like it will in practice?

Done.

@craig craig bot merged commit addc64f into cockroachdb:master Apr 9, 2024
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-24.1.x Flags PRs that need to be backported to 24.1.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants