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

session: fix panic when storing outdated plans from plan cache (#19296) #20246

Merged
merged 6 commits into from
Oct 14, 2020

Conversation

ti-srebot
Copy link
Contributor

cherry-pick #19296 to release-4.0


What problem does this PR solve?

Issue Number: close #19192

Problem Summary:

Panic instead of error for queries when plan cache is enabled.

What is changed and how it works?

What's Changed:

Reset session.currentPlan to nil after storing it into ProcessInfo.

How it Works:

The root cause of the panic is that, if a query raises error before storing its plan into session.currentPlan, e.g, error happens in optimizer, then the session.currentPlan is not updated, i.e, it is the plan for the former query, so after returned to dispatch -> SetProcessInfo, the plan is accessed again, while the params have already gone, so panic happens.

Reset session.currentPlan to nil after storing it into ProcessInfo, then for the next query, even if it fails to update session.currentPlan, there is no risk to access an outdated plan then.

Related changes

  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test

Side effects

N/A

Release note

  • Fix panic when storing outdated plans from plan cache

Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor Author

/run-all-tests

@eurekaka
Copy link
Contributor

/run-check_dev

Copy link
Member

@wjhuang2016 wjhuang2016 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-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Sep 27, 2020
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

@ti-srebot ti-srebot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Oct 9, 2020
@zz-jason
Copy link
Member

zz-jason commented Oct 9, 2020

/merge

@ti-srebot ti-srebot added the status/can-merge Indicates a PR has been approved by a committer. label Oct 9, 2020
@ti-srebot
Copy link
Contributor Author

/run-all-tests

@ti-srebot
Copy link
Contributor Author

@ti-srebot merge failed.

@eurekaka eurekaka merged commit 84b22ca into pingcap:release-4.0 Oct 14, 2020
@eurekaka eurekaka deleted the release-4.0-486e473a86e9 branch October 14, 2020 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
challenge-program epic/plan-cache sig/execution SIG execution sig/planner SIG: Planner 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/4.0-cherry-pick
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants