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: introduce tidb_general_plan_cache_size for general plan cache #37087
planner: introduce tidb_general_plan_cache_size for general plan cache #37087
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. |
Code Coverage Details: https://codecov.io/github/pingcap/tidb/commit/0537a98d34f4b0c403b23d388315c24d0342f952 |
/label epic/plan-cache |
@fzzf678: The label(s) In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
/cc @qw4990 @Reminiscent |
sessionctx/variable/sysvar.go
Outdated
@@ -854,6 +854,15 @@ var defaultSysVars = []*SysVar{ | |||
}, GetGlobal: func(s *SessionVars) (string, error) { | |||
return BoolToOnOff(EnableTmpStorageOnOOM.Load()), nil | |||
}}, | |||
{Scope: ScopeGlobal, Name: TiDBGeneralPlanCacheSize, Value: strconv.FormatUint(uint64(DefTiDBGeneralPlanCacheSize), 10), Type: TypeUnsigned, MinValue: 0, MaxValue: 100000, SetGlobal: func(s *SessionVars, val string) error { |
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.
Should be ScopeGlobal | ScopeSession
.
sessionctx/variable/sysvar_test.go
Outdated
@@ -1159,3 +1159,25 @@ func TestSetTIDBDiskQuota(t *testing.T) { | |||
require.NoError(t, err) | |||
require.Equal(t, strconv.FormatInt(pb, 10), val) | |||
} | |||
|
|||
func TestGeneralPlanCache(t *testing.T) { |
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.
Please add your test into executor/set_test.go:TestSetVar
.
sessionctx/variable/sysvar.go
Outdated
return err | ||
}, GetGlobal: func(s *SessionVars) (string, error) { | ||
return strconv.FormatUint(GeneralPlanCacheSize.Load(), 10), nil | ||
}}, | ||
|
||
/* The system variables below have GLOBAL and SESSION scope */ |
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.
The new added global && session
variables should be added to this part.
sessionctx/variable/tidb_vars.go
Outdated
@@ -791,6 +791,8 @@ const ( | |||
TiDBDDLEnableFastReorg = "tidb_ddl_fast_reorg" | |||
// TiDBDDLDiskQuota used to set disk quota for lightning add index. | |||
TiDBDDLDiskQuota = "tidb_ddl_disk_quota" | |||
// TiDBGeneralPlanCacheSize controls the size of general plan cache. 0 indicate close. | |||
TiDBGeneralPlanCacheSize = "tidb_general_plan_cache_size" |
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 list keeps the global-only
variables. See line 722.
sessionctx/variable/tidb_vars.go
Outdated
// GeneralPlanCacheSize is a variable for general plan cache | ||
GeneralPlanCacheSize = atomic.NewUint64(DefTiDBGeneralPlanCacheSize) |
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.
Shouldn't put the GeneralPlanCacheSize
here. The list only contains the global-only
variables. See line 1019
s.EnableGeneralPlanCache = TiDBOptOn(val) | ||
return nil | ||
}}, | ||
{Scope: ScopeGlobal | ScopeSession, Name: TiDBGeneralPlanCacheSize, Value: strconv.FormatUint(uint64(DefTiDBGeneralPlanCacheSize), 10), Type: TypeUnsigned, MinValue: 0, MaxValue: 100000, SetSession: func(s *SessionVars, val string) error { |
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.
It seems the minValue for TiDBPrepPlanCacheSize is 1. See line 781. Should we keep them the same?
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.
Maybe we can change this in the next PR or maybe not changed. Both is OK for me.
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.
Maybe we can change this in the next PR or maybe not changed. Both is OK for me.
Got it. Before, minValue = 0 is used to let the general plan cache OFF, I forget to revised back. I 'll fix it in next pr.
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 0537a98
|
TiDB MergeCI notify🔴 Bad News! New failing [1] after this pr merged.
|
What problem does this PR solve?
Issue Number: ref #36598
Problem Summary:
Control the general plan cache size and on/off
What is changed and how it works?
Introduce global variable
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.