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

server: add tidb_enable_shared_lock_promotion to support for share lock upgrade #55023

Merged
merged 8 commits into from
Aug 8, 2024

Conversation

cfzjywxk
Copy link
Contributor

@cfzjywxk cfzjywxk commented Jul 29, 2024

What problem does this PR solve?

Issue Number: close #55022

Problem Summary:

  1. Support tidb_enable_shared_lock_promotion to achive that the for share statements could be executed like for update statements which acquire pessimistic locks.
  2. Fix serveral issues when tidb_enable_noop_functions is enabled, the behaviours of select for share are unexpected, including:
  • When nowait is used, the execution is not no-op actually.
  • When tidb_enable_noop_functions is set to off, the select for share DOES acquire locks, so is on.
  1. Refactor the behaviours of tidb_enable_noop_functions, tidb_enabled_shared_lock_promotion and for share statements for executions with PointGet and Coprocessor pathes.

What changed and how does it work?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

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

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

Introduce `tidb_enable_shared_lock_promotion` to support `for share` statements could be executed like `for update` statements which acquire pessimistic locks.

@ti-chi-bot ti-chi-bot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. sig/planner SIG: Planner labels Jul 29, 2024
Copy link

tiprow bot commented Jul 29, 2024

Hi @cfzjywxk. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link

codecov bot commented Jul 29, 2024

Codecov Report

Attention: Patch coverage is 76.92308% with 9 lines in your changes missing coverage. Please review.

Project coverage is 74.8339%. Comparing base (3357f26) to head (5715a91).
Report is 4 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #55023        +/-   ##
================================================
+ Coverage   72.8630%   74.8339%   +1.9708%     
================================================
  Files          1570       1570                
  Lines        439501     441345      +1844     
================================================
+ Hits         320234     330276     +10042     
+ Misses        99523      90819      -8704     
- Partials      19744      20250       +506     
Flag Coverage Δ
integration 49.0120% <76.9230%> (?)
unit 71.8155% <52.7777%> (-0.0932%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.9567% <ø> (ø)
parser ∅ <ø> (∅)
br 52.5187% <ø> (+6.6533%) ⬆️

@cfzjywxk cfzjywxk requested review from bb7133 and tangenta July 29, 2024 11:28

// TiDBEnableSharedLockUpgrade indicates whether the `select for share` statement would be executed
// as `select for update` statements which do acquire pessimistic locks.
TiDBEnableSharedLockUpgrade = "tidb_enable_shared_lock_upgrade"

Choose a reason for hiding this comment

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

LGTM

@cfzjywxk cfzjywxk force-pushed the for_share_upgrade branch 2 times, most recently from f431b78 to 27d3910 Compare August 8, 2024 03:11
@easonn7
Copy link

easonn7 commented Aug 8, 2024

/approve

@pingcap pingcap deleted a comment from ti-chi-bot bot Aug 8, 2024
@cfzjywxk cfzjywxk force-pushed the for_share_upgrade branch from 0f62d9a to eb9160f Compare August 8, 2024 04:42
@cfzjywxk cfzjywxk changed the title server: add tidb_enable_shared_lock_upgrade to support for share lock upgrade server: add tidb_enable_shared_lock_promotion to support for share lock upgrade Aug 8, 2024
@cfzjywxk cfzjywxk force-pushed the for_share_upgrade branch from eb9160f to 589c5bc Compare August 8, 2024 06:50
@cfzjywxk cfzjywxk requested a review from BornChanger August 8, 2024 06:50
Copy link
Contributor

@BornChanger BornChanger left a comment

Choose a reason for hiding this comment

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

we need to claim tidb_enable_shared_lock_promotion will override tidb_enable_noop_functions in release notes.
others lgtm.

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Aug 8, 2024

// TiDBEnableSharedLockPromotion indicates whether the `select for share` statement would be executed
// as `select for update` statements which do acquire pessimistic locks.
TiDBEnableSharedLockPromotion = "tidb_enable_shared_lock_promotion"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add this new variable into the Plan Cache Key? Otherwise the optimizer might reuse an old plan after switching this variable, which might cause some problem.

@cfzjywxk cfzjywxk force-pushed the for_share_upgrade branch from 589c5bc to 5715a91 Compare August 8, 2024 09:49
@cfzjywxk cfzjywxk requested a review from qw4990 August 8, 2024 09:50
Copy link
Contributor

@qw4990 qw4990 left a comment

Choose a reason for hiding this comment

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

LGTM for the optimizer part

Copy link

ti-chi-bot bot commented Aug 8, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: BornChanger, easonn7, qw4990

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

The pull request process is described here

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 approved lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Aug 8, 2024
Copy link

ti-chi-bot bot commented Aug 8, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-08-08 06:54:25.504946491 +0000 UTC m=+507795.372045580: ☑️ agreed by BornChanger.
  • 2024-08-08 09:54:20.176460006 +0000 UTC m=+518590.043559094: ☑️ agreed by qw4990.

@cfzjywxk
Copy link
Contributor Author

cfzjywxk commented Aug 8, 2024

/retest

Copy link

tiprow bot commented Aug 8, 2024

@cfzjywxk: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot ti-chi-bot bot merged commit 99857e3 into pingcap:master Aug 8, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/planner SIG: Planner sig/transaction SIG:Transaction size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/new-feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

txn: support upgrade for share clause to for update
5 participants