Skip to content

Commit

Permalink
sessionctx/variable: change tidb_store_limit to global only (#30522)
Browse files Browse the repository at this point in the history
  • Loading branch information
morgo committed Dec 15, 2021
1 parent 6c0fcea commit 813f6ef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
11 changes: 3 additions & 8 deletions executor/set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,16 +366,11 @@ func (s *testSerialSuite1) TestSetVar(c *C) {
tk.MustExec("set @@tidb_expensive_query_time_threshold=70")
tk.MustQuery("select @@tidb_expensive_query_time_threshold;").Check(testkit.Rows("70"))

tk.MustQuery("select @@tidb_store_limit;").Check(testkit.Rows("0"))
tk.MustExec("set @@tidb_store_limit = 100")
tk.MustQuery("select @@tidb_store_limit;").Check(testkit.Rows("100"))
tk.MustQuery("select @@session.tidb_store_limit;").Check(testkit.Rows("100"))
tk.MustQuery("select @@global.tidb_store_limit;").Check(testkit.Rows("0"))
tk.MustExec("set @@tidb_store_limit = 0")

tk.MustExec("set @@global.tidb_store_limit = 100")
tk.MustQuery("select @@global.tidb_store_limit;").Check(testkit.Rows("100"))
tk.MustExec("set @@global.tidb_store_limit = 0")
tk.MustExec("set global tidb_store_limit = 100")
tk.MustQuery("select @@tidb_store_limit;").Check(testkit.Rows("100"))
tk.MustQuery("select @@session.tidb_store_limit;").Check(testkit.Rows("100"))
tk.MustQuery("select @@global.tidb_store_limit;").Check(testkit.Rows("100"))

tk.MustQuery("select @@session.tidb_metric_query_step;").Check(testkit.Rows("60"))
Expand Down
5 changes: 1 addition & 4 deletions sessionctx/variable/sysvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -1036,10 +1036,7 @@ var defaultSysVars = []*SysVar{
}
return nil
}},
{Scope: ScopeGlobal | ScopeSession, Name: TiDBStoreLimit, Value: strconv.FormatInt(atomic.LoadInt64(&config.GetGlobalConfig().TiKVClient.StoreLimit), 10), Type: TypeInt, MinValue: 0, MaxValue: math.MaxInt64, SetSession: func(s *SessionVars, val string) error {
tikvstore.StoreLimit.Store(tidbOptInt64(val, DefTiDBStoreLimit))
return nil
}, GetSession: func(s *SessionVars) (string, error) {
{Scope: ScopeGlobal, Name: TiDBStoreLimit, Value: strconv.FormatInt(atomic.LoadInt64(&config.GetGlobalConfig().TiKVClient.StoreLimit), 10), Type: TypeInt, MinValue: 0, MaxValue: math.MaxInt64, GetGlobal: func(s *SessionVars) (string, error) {
return strconv.FormatInt(tikvstore.StoreLimit.Load(), 10), nil
}, SetGlobal: func(s *SessionVars, val string) error {
tikvstore.StoreLimit.Store(tidbOptInt64(val, DefTiDBStoreLimit))
Expand Down

0 comments on commit 813f6ef

Please sign in to comment.