Skip to content

txn: support shared lock for lock wait table#19094

Merged
you06 merged 7 commits intotikv:tikv-8.5-with-shared-lockfrom
you06:8.5-shared-lock/wait-table
Nov 13, 2025
Merged

txn: support shared lock for lock wait table#19094
you06 merged 7 commits intotikv:tikv-8.5-with-shared-lockfrom
you06:8.5-shared-lock/wait-table

Conversation

@you06
Copy link
Contributor

@you06 you06 commented Nov 7, 2025

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

you06 added 6 commits November 7, 2025 11:29
Signed-off-by: you06 <you1474600@gmail.com>
Signed-off-by: you06 <you1474600@gmail.com>
Signed-off-by: you06 <you1474600@gmail.com>
Signed-off-by: you06 <you1474600@gmail.com>
Signed-off-by: you06 <you1474600@gmail.com>
Signed-off-by: you06 <you1474600@gmail.com>
@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 Nov 7, 2025
@zyguan zyguan mentioned this pull request Nov 7, 2025
13 tasks
Signed-off-by: you06 <you1474600@gmail.com>
@you06 you06 requested review from cfzjywxk and zyguan November 10, 2025 04:55
@cfzjywxk cfzjywxk requested a review from MyonKeminta November 10, 2025 06:34
self.mock_lock_wait_with_shared(key, start_ts, encountered_lock_ts, resumable, false)
}

fn mock_lock_wait_with_shared(
Copy link
Collaborator

Choose a reason for hiding this comment

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

It is confusing to name it must lock with shared while having a shared parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

..._with_shared means accept a shared parameter, and such naming habit is common in the codebase.

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Nov 10, 2025
cmd.keys.iter().any(|k| k.2)
} else {
false
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Could AcquirePessimisticLockResumed write shared locks?

Copy link
Contributor Author

@you06 you06 Nov 12, 2025

Choose a reason for hiding this comment

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

No, AcquirePessimisticLockResumed schedulers are only created in force lock(lock_with_conflict), and all the shared locks go through normal pessimistic lock process.

let allow_lock_with_conflict = match req.get_wake_up_mode() {
PessimisticLockWakeUpMode::WakeUpModeNormal => false,
PessimisticLockWakeUpMode::WakeUpModeForceLock => true,
};

After the lock wait is resumed, allow_lock_with_conflict schedulers can return a woken_up_resumable_entry.

if lock_wait_entry.parameters.allow_lock_with_conflict {
woken_up_resumable_entry = Some(lock_wait_entry);
break;
}

Then if woken_up_resumable_entry is not none, the delay_wake_up_futures will be cast into AcquirePessimisticLockResumed

if !legacy_wake_up_list.is_empty() || !delay_wake_up_futures.is_empty() {
self.wake_up_legacy_pessimistic_locks(
request_source,
metadata.clone(),
legacy_wake_up_list,
delay_wake_up_futures,
);
}

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Nov 13, 2025

[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 Nov 13, 2025
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Nov 13, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-11-10 06:45:10.316724621 +0000 UTC m=+684559.759754490: ☑️ agreed by cfzjywxk.
  • 2025-11-13 03:47:29.299292291 +0000 UTC m=+933098.742322170: ☑️ agreed by zyguan.

@you06 you06 merged commit 03eebcd into tikv:tikv-8.5-with-shared-lock Nov 13, 2025
2 of 3 checks passed
you06-pingcap pushed a commit to you06/tikv that referenced this pull request Nov 27, 2025
* 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>
you06-pingcap pushed a commit to you06/tikv that referenced this pull request Jan 5, 2026
* 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>
you06-pingcap pushed a commit to you06/tikv that referenced this pull request Jan 6, 2026
* 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>
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.

3 participants