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 wrong PointGet / TableDual plan reused in plan cache (#23238) #24043

Merged
merged 2 commits into from
Apr 16, 2021

Conversation

ti-srebot
Copy link
Contributor

@ti-srebot ti-srebot commented Apr 15, 2021

cherry-pick #23238 to release-5.0
You can switch your code base to this Pull Request by using git-extras:

# In tidb repo:
git pr https://github.com/pingcap/tidb/pull/24043

After apply modifications, you can push your change to this PR via:

git push [email protected]:ti-srebot/tidb.git pr/24043:release-5.0-1ac53c546d9e

What problem does this PR solve?

Issue Number: close #23187
close #23144
close #23304
close #23290

Problem Summary:

Planner cannot find a plan for a query while it indeed can.

What is changed and how it works?

What's Changed:

  • if we prune paths in DeriveStats and only keep the TableDual / PointGet path, we mark this plan as not cacheable;
  • in skylinePruning we can enable the early return now if we find a path with empty range;

How it Works:

These plans have strong dependency on the param values, i.e, if the values change, those plans may lead to wrong query results.

Related changes

N/A

Check List

Tests

  • Unit test

Side effects

  • Performance regression
    • This may prevent some plans which have TableDual / PointGet from being cached, while those TableDual / PointGet may have no relationship with param values at all. For example, plan for query prepare stmt from 'select * from t1, t2 where t1.a > 9 and t1.a < 0 and t2.a > ? and t1.b = t2.b' cannot be cached then, but it is safe actually.

Release note

  • Fix wrong PointGet / TableDual plan reused in plan cache

@ti-srebot ti-srebot requested review from a team as code owners April 15, 2021 06:29
@ti-srebot ti-srebot requested review from qw4990 and XuHuaiyu and removed request for a team April 15, 2021 06:29
@ti-srebot
Copy link
Contributor Author

/run-all-tests

@ti-srebot ti-srebot added epic/plan-cache sig/execution SIG execution sig/planner SIG: Planner size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/5.0-cherry-pick type/bugfix This PR fixes a bug. labels Apr 15, 2021
@ti-srebot ti-srebot added this to the v5.0.0 ga milestone Apr 15, 2021
@ti-srebot
Copy link
Contributor Author

@eurekaka you're already a collaborator in bot's repo.

@eurekaka eurekaka added the priority/release-blocker This issue blocks a release. Please solve it ASAP. label Apr 15, 2021
Copy link
Member

@time-and-fate time-and-fate 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 added the status/LGT1 Indicates that a PR has LGTM 1. label Apr 15, 2021
@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • qw4990
  • time-and-fate

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Reviewer can indicate their review by writing /lgtm in a comment.
Reviewer can cancel approval by writing /lgtm cancel in a comment.

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Apr 15, 2021
@zhouqiang-cl zhouqiang-cl added the cherry-pick-approved Cherry pick PR approved by release team. label Apr 15, 2021
@eurekaka
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 15e10c9

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Apr 16, 2021
@ti-chi-bot ti-chi-bot merged commit 4c49754 into pingcap:release-5.0 Apr 16, 2021
@eurekaka eurekaka deleted the release-5.0-1ac53c546d9e branch April 16, 2021 03:24
@zhouqiang-cl zhouqiang-cl modified the milestones: v5.0.0 ga, v5.0.1 Apr 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick-approved Cherry pick PR approved by release team. epic/plan-cache priority/release-blocker This issue blocks a release. Please solve it ASAP. sig/execution SIG execution sig/planner SIG: Planner size/L Denotes a PR that changes 100-499 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/bugfix This PR fixes a bug. type/5.0-cherry-pick
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants