Skip to content

txn: support shared lock for lock wait table#19271

Merged
ti-chi-bot[bot] merged 6 commits intotikv:masterfrom
you06:master-shared-lock/wait
Jan 9, 2026
Merged

txn: support shared lock for lock wait table#19271
ti-chi-bot[bot] merged 6 commits intotikv:masterfrom
you06:master-shared-lock/wait

Conversation

@you06
Copy link
Contributor

@you06 you06 commented Jan 6, 2026

What is changed and how it works?

Issue Number: ref #19087

What's Changed:

Handle the shared lock in the lock wait table.

Related changes

  • PR to update pingcap/docs/pingcap/docs-cn:
  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Release note

None

* implement lock waiting queue

Signed-off-by: you06 <you1474600@gmail.com>

* donot track shared lock in deadlock detector

Signed-off-by: you06 <you1474600@gmail.com>

* support lock wakeup for shared lock

Signed-off-by: you06 <you1474600@gmail.com>

* fmt code

Signed-off-by: you06 <you1474600@gmail.com>

* rename param

Signed-off-by: you06 <you1474600@gmail.com>

* remove unused test function

Signed-off-by: you06 <you1474600@gmail.com>

* boxed LockWaitEntry

Signed-off-by: you06 <you1474600@gmail.com>

---------

Signed-off-by: you06 <you1474600@gmail.com>
Copilot AI review requested due to automatic review settings January 6, 2026 08:38
@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates the PR's author has signed the dco. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 6, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for shared locks in the lock wait table, enabling multiple waiters for shared locks to be woken up simultaneously when a conflicting lock is released. This is preparatory work for full shared lock support.

Key changes:

  • Extended AcquirePessimisticLock command to accept 3-tuple keys (key, should_not_exist, is_shared_lock)
  • Modified lock wait queue to group and wake up consecutive shared lock waiters together
  • Added detection and handling for shared lock commands to disable in-memory pessimistic lock optimization
  • Excluded shared locks from deadlock detection

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/storage/txn/commands/acquire_pessimistic_lock.rs Updated key tuple format to include is_shared_lock flag
src/storage/lock_manager/lock_waiting_queue.rs Implemented group wake-up logic for consecutive shared lock waiters
src/storage/txn/scheduler.rs Added shared lock command detection and modified wake-up handling to process multiple entries
src/server/lock_manager/mod.rs Excluded shared locks from deadlock detection
src/storage/mod.rs Updated test helper functions to support new 3-tuple format
src/storage/txn/commands/mod.rs Updated protocol buffer conversion to extract shared lock flag
tests/failpoints/cases/test_storage.rs Updated test cases to use new 3-tuple format
Multiple test files Added is_shared_lock field initialization in test code

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

you06 added 2 commits January 6, 2026 21:08
Signed-off-by: you06 <you1474600@gmail.com>
Signed-off-by: you06 <you1474600@gmail.com>
@you06
Copy link
Contributor Author

you06 commented Jan 6, 2026

/retest

@you06 you06 mentioned this pull request Jan 7, 2026
13 tasks
@you06 you06 requested review from cfzjywxk and zyguan January 8, 2026 05:06
Signed-off-by: you06 <you1474600@gmail.com>
@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Jan 8, 2026
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Jan 8, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cfzjywxk, zyguan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jan 8, 2026
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Jan 8, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-01-08 09:30:29.840197978 +0000 UTC m=+867385.658506400: ☑️ agreed by zyguan.
  • 2026-01-08 10:43:03.66001581 +0000 UTC m=+871739.478324242: ☑️ agreed by cfzjywxk.

@you06
Copy link
Contributor Author

you06 commented Jan 8, 2026

/retest

@you06
Copy link
Contributor Author

you06 commented Jan 8, 2026

The clippy failed because aws-sdk-s3 is pinned to lru ^0.12.2, which violates RUSTSEC-2026-0002.

you06 added 2 commits January 9, 2026 14:06
Signed-off-by: you06 <you1474600@gmail.com>
Signed-off-by: you06 <you1474600@gmail.com>
# aws-sdk-s3 transitively depends on lru 0.12.x, which triggers
# RUSTSEC-2026-0002 (Stacked Borrows UB). Upstream dependency
# constraints prevent upgrading at the moment.
"RUSTSEC-2026-0002",
Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

Choose a reason for hiding this comment

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

LGTM

@you06
Copy link
Contributor Author

you06 commented Jan 9, 2026

/retest

@ti-chi-bot ti-chi-bot bot merged commit 14cbb90 into tikv:master Jan 9, 2026
9 checks passed
@ti-chi-bot ti-chi-bot bot added this to the Pool milestone Jan 9, 2026
ti-chi-bot bot pushed a commit that referenced this pull request Jan 13, 2026
ref #19249

Fix the CI by ignoring `RUSTSEC-2026-0002`.

Signed-off-by: you06 <you1474600@gmail.com>
ekexium pushed a commit to ti-chi-bot/tikv that referenced this pull request Jan 19, 2026
ref tikv#19249

Fix the CI by ignoring `RUSTSEC-2026-0002`.

Signed-off-by: you06 <you1474600@gmail.com>
you06-pingcap pushed a commit to you06/tikv that referenced this pull request Feb 27, 2026
ref tikv#19087

Handle the shared lock in the lock wait table.

Signed-off-by: you06 <you1474600@gmail.com>
ti-chi-bot bot pushed a commit that referenced this pull request Mar 3, 2026
ref #19087

Handle the shared lock in the lock wait table.

Signed-off-by: you06 <you1474600@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved dco-signoff: yes Indicates the PR's author has signed the dco. lgtm release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants