planner: check schema stale for plan cache when forUpdateRead#22381
Merged
Conversation
Signed-off-by: you06 <you1474600@gmail.com>
Signed-off-by: you06 <you1474600@gmail.com>
Contributor
|
LGTM |
ti-srebot
previously approved these changes
Jan 14, 2021
Contributor
Author
|
Do not merge this PR now. |
Signed-off-by: you06 <you1474600@gmail.com>
you06
commented
Jan 15, 2021
| c.Assert(err, IsNil) | ||
| tk2.CheckExecResult(1, 0) | ||
| // FIXME: should hit plan cache here | ||
| tk2.MustQuery("select @@last_plan_from_cache").Check(testkit.Rows("0")) |
Contributor
Author
There was a problem hiding this comment.
There still exist a problem, plan cache will not hit here.
Signed-off-by: you06 <you1474600@gmail.com>
you06
commented
Jan 21, 2021
| delete(sessVars.IsolationReadEngines, kv.TiFlash) | ||
| cacheKey = NewPSTMTPlanCacheKey(sctx.GetSessionVars(), e.ExecID, prepared.SchemaVersion) | ||
| sessVars.IsolationReadEngines[kv.TiFlash] = struct{}{} | ||
| } |
Contributor
Author
There was a problem hiding this comment.
When use binary protocol and the plan cache is not hit, a new cache will generate inside getPhysicalPlan function, in which use the following codes to exclude TiFlash engine for write statement.
Lines 85 to 88 in 2364fec
After the plan is builing complete, the
TiFlash engine is set back and the it'll still write a plan-cache key with TiFlash engine. As a result, we cache a write plan for TiFlash engine, and it'll never be used correctly.
Contributor
Author
Signed-off-by: you06 <you1474600@gmail.com>
Contributor
Author
|
I think this bug is serious, @winoros can you help reviewing it? Thanks! |
Contributor
Contributor
|
@you06 |
Signed-off-by: you06 <you1474600@gmail.com>
Signed-off-by: you06 <you1474600@gmail.com>
winoros
approved these changes
Mar 19, 2021
Member
|
/merge |
Member
|
This pull request has been accepted and is ready to merge. DetailsCommit hash: 5702b0e |
ti-srebot
pushed a commit
to ti-srebot/tidb
that referenced
this pull request
Mar 19, 2021
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
Contributor
|
cherry pick to release-5.0 in PR #23435 |
SabaPing
pushed a commit
to SabaPing/tidb
that referenced
this pull request
Mar 25, 2021
ti-chi-bot
pushed a commit
that referenced
this pull request
Mar 26, 2021
12 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
Issue Number: #21498 will also affected plan cache.
Problem Summary:
What is changed and how it works?
What's Changed: when the plan is using forUpdateRead, we need to use the latest schema to check if plan is valid.
How it Works:
Update schema version when required.
Related changes
Check List
Tests
Release note