-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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: refactor the IsolationReadEngines variable for plan cache #36770
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
planner/core/planbuilder.go
Outdated
@@ -1256,7 +1256,7 @@ func filterPathByIsolationRead(ctx sessionctx.Context, paths []*util.AccessPath, | |||
if dbName.L == mysql.SystemDB { | |||
return paths, nil | |||
} | |||
isolationReadEngines := ctx.GetSessionVars().GetIsolationReadEngines() | |||
isolationReadEngines := GetAvailableIsolationReadEngines4Plan(ctx.GetSessionVars()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only here in the optimize phase need the isolationReadEngines
. But it's not easy to get the ast
here. So we can not directly use IsReadOnly
function to check. So we store the IsReadyOnlyStmt
in advance.
planner/core/plan_cache.go
Outdated
// rebuild key to exclude kv.TiFlash when stmt is not read only | ||
if _, isolationReadContainTiFlash := sessVars.IsolationReadEngines[kv.TiFlash]; isolationReadContainTiFlash && !IsReadOnly(stmt, sessVars) { | ||
delete(sessVars.IsolationReadEngines, kv.TiFlash) | ||
if cacheKey, err = NewPlanCacheKey(sessVars, preparedStmt.StmtText, preparedStmt.StmtDB, | ||
prepared.SchemaVersion, latestSchemaVersion); err != nil { | ||
return nil, nil, err | ||
} | ||
sessVars.IsolationReadEngines[kv.TiFlash] = struct{}{} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part is useless here. We needn't handle the session variables in advance. Just use its original values.
Code Coverage Details: https://codecov.io/github/pingcap/tidb/commit/d8ae853312d7a0a241db54ce855aef834655ca6c |
/run-all-tests |
because the CI upgrade go1.18.5. so I sync the code with master. |
…ctor-read-engines
…ctor-read-engines
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 2f1e9ea
|
/merge |
3 similar comments
/merge |
/merge |
/merge |
/merge |
/merge |
/run-unit-test |
TiDB MergeCI notify🔴 Bad News! New failing [1] after this pr merged.
|
What problem does this PR solve?
Issue Number: ref #36598
Problem Summary: planner: refactor the IsolationReadEngines variable for plan cache
What is changed and how it works?
IsolationReadEngines
in variables.GetIsolationReadEngines
to access theIsolationReadEngines
values.GetAvailableIsolationReadEngines4Plan
function to get the available isolation read engines. Not delete the tif lash engine first and add it later.Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.