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

planner: fix incorrectly using the schema for plan cache #57964

Merged
merged 5 commits into from
Dec 9, 2024

Conversation

wjhuang2016
Copy link
Member

@wjhuang2016 wjhuang2016 commented Dec 4, 2024

What problem does this PR solve?

Issue Number: close #56733

Problem Summary:
If the table ID is changed for a given table name, the plan cache key is not updated.
For an insert statement, it may use the outdated schema, resulting in incorrect data or query results.

What changed and how does it work?

Make sure the tbl is updated in function planCachePreprocess() if tableByID doesn't return the table info.

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 incorrectly using the schema for plan cache

Signed-off-by: wjhuang2016 <[email protected]>
@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue do-not-merge/needs-tests-checked release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed do-not-merge/needs-linked-issue labels Dec 4, 2024
Copy link

codecov bot commented Dec 4, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 74.7843%. Comparing base (d021648) to head (c965705).
Report is 27 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #57964        +/-   ##
================================================
+ Coverage   73.1421%   74.7843%   +1.6422%     
================================================
  Files          1671       1719        +48     
  Lines        460703     475114     +14411     
================================================
+ Hits         336968     355311     +18343     
+ Misses       102998      97476      -5522     
- Partials      20737      22327      +1590     
Flag Coverage Δ
integration 49.0871% <50.0000%> (?)
unit 72.2772% <50.0000%> (+0.0027%) ⬆️

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

Components Coverage Δ
dumpling 52.6910% <ø> (ø)
parser ∅ <ø> (∅)
br 61.6530% <ø> (+15.6636%) ⬆️

Signed-off-by: wjhuang2016 <[email protected]>
Signed-off-by: wjhuang2016 <[email protected]>
@wjhuang2016 wjhuang2016 changed the title planner: fix incorrect handle the schema for plan cache planner: fix incorrectly using the schema for plan cache Dec 4, 2024
@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. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Dec 4, 2024
pkg/planner/core/plan_cache.go Show resolved Hide resolved
pkg/planner/core/plan_cache.go Show resolved Hide resolved
pkg/ddl/tests/metadatalock/mdl_test.go Show resolved Hide resolved
Signed-off-by: wjhuang2016 <[email protected]>
Signed-off-by: wjhuang2016 <[email protected]>
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Dec 6, 2024
@wjhuang2016
Copy link
Member Author

/retest

Copy link
Contributor

@zimulala zimulala 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 lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Dec 9, 2024
Copy link

ti-chi-bot bot commented Dec 9, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-12-06 09:41:27.704097415 +0000 UTC m=+1407075.323751936: ☑️ agreed by tangenta.
  • 2024-12-09 07:25:48.182836306 +0000 UTC m=+250538.271638849: ☑️ agreed by zimulala.

Copy link

ti-chi-bot bot commented Dec 9, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: qw4990, tangenta, zimulala

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 the approved label Dec 9, 2024
@ti-chi-bot ti-chi-bot bot merged commit 6b17068 into pingcap:master Dec 9, 2024
27 checks passed
@wjhuang2016
Copy link
Member Author

/run-cherry-picker release-8.5

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

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

@wjhuang2016 wjhuang2016 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. needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. labels Dec 9, 2024
ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Dec 9, 2024
@ti-chi-bot
Copy link
Member

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

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

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

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

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

@ti-chi-bot
Copy link
Member

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

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. needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 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
Development

Successfully merging this pull request may close these issues.

data inconsistency in table after injection one of tikv network partition during adding index
5 participants