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

*: add metadata lock when using the plan cache #51897

Merged
merged 29 commits into from
Apr 28, 2024

Conversation

wjhuang2016
Copy link
Member

@wjhuang2016 wjhuang2016 commented Mar 19, 2024

What problem does this PR solve?

Issue Number: close #51407

Problem Summary:
When executing the prepared statement from the plan cache, tidb doesn't add the metadata lock, which may cause data-index inconsistency.

What changed and how does it work?

  1. Collect the related table information when PREPARE.
  2. Add metadata lock during planCachePreprocess. If the schema is changed, can't use the cache plan anymore.

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.

fix a bug that metadata lock is missing when using the plan cache

Signed-off-by: wjhuang2016 <[email protected]>
@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-tests-checked 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. and removed do-not-merge/needs-tests-checked labels Mar 19, 2024
Copy link

codecov bot commented Mar 19, 2024

Codecov Report

Attention: Patch coverage is 82.50000% with 14 lines in your changes are missing coverage. Please review.

Project coverage is 56.4929%. Comparing base (da775f6) to head (2e61168).
Report is 129 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #51897         +/-   ##
=================================================
- Coverage   72.1372%   56.4929%   -15.6444%     
=================================================
  Files          1467       1599        +132     
  Lines        426900     621672     +194772     
=================================================
+ Hits         307954     351201      +43247     
- Misses        99709     246773     +147064     
- Partials      19237      23698       +4461     
Flag Coverage Δ
integration 37.3137% <76.2500%> (?)
unit 71.2355% <82.5000%> (+0.2264%) ⬆️

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

Components Coverage Δ
dumpling 53.9957% <ø> (ø)
parser ∅ <ø> (∅)
br 47.6298% <ø> (+6.5448%) ⬆️

Signed-off-by: wjhuang2016 <[email protected]>
Signed-off-by: wjhuang2016 <[email protected]>
Copy link
Collaborator

@Benjamin2037 Benjamin2037 left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Mar 20, 2024
Signed-off-by: wjhuang2016 <[email protected]>
@wjhuang2016
Copy link
Member Author

/retest

Signed-off-by: wjhuang2016 <[email protected]>
@ti-chi-bot ti-chi-bot bot removed the approved label Mar 22, 2024
@wuhuizuo
Copy link
Contributor

/test check-dev

Copy link

tiprow bot commented Mar 22, 2024

@wuhuizuo: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test fast_test_tiprow
  • /test tidb_parser_test

Use /test all to run all jobs.

In response to this:

/test check-dev

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/test-infra repository.

@@ -542,6 +542,8 @@ type TableInfo struct {

TTLInfo *TTLInfo `json:"ttl_info"`

TableVersion uint64 `json:"table_version"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe ModificationCount is better.

Copy link
Contributor

@zimulala zimulala Mar 22, 2024

Choose a reason for hiding this comment

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

Please add a comment here. In particular, explain how "ModificationCount" differs from "Version".

Signed-off-by: wjhuang2016 <[email protected]>
@wjhuang2016
Copy link
Member Author

/retest

1 similar comment
@wjhuang2016
Copy link
Member Author

/retest

Signed-off-by: wjhuang2016 <[email protected]>
Signed-off-by: wjhuang2016 <[email protected]>
Signed-off-by: wjhuang2016 <[email protected]>
Signed-off-by: wjhuang2016 <[email protected]>
Signed-off-by: wjhuang2016 <[email protected]>
@wjhuang2016
Copy link
Member Author

/retest

Signed-off-by: wjhuang2016 <[email protected]>
Signed-off-by: wjhuang2016 <[email protected]>
@ti-chi-bot ti-chi-bot bot added the approved label Apr 28, 2024
@wjhuang2016
Copy link
Member Author

/retest

2 similar comments
@wjhuang2016
Copy link
Member Author

/retest

@wjhuang2016
Copy link
Member Author

/retest

@ti-chi-bot ti-chi-bot bot merged commit 70a8253 into pingcap:master Apr 28, 2024
19 of 23 checks passed
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Apr 28, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.0: #52954.

@ti-chi-bot ti-chi-bot added the needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. label Apr 28, 2024
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Apr 28, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.1: #52955.

@Benjamin2037 Benjamin2037 added needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. labels Apr 28, 2024
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Apr 28, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.5: #52956.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Apr 28, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #52957.

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Apr 28, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.1: #52958.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/planner SIG: Planner size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
8 participants