From 813f6efd41ce3276e5737efa5734c1795048477a Mon Sep 17 00:00:00 2001 From: Morgan Tocker Date: Tue, 14 Dec 2021 18:40:35 -0700 Subject: [PATCH] sessionctx/variable: change tidb_store_limit to global only (#30522) --- executor/set_test.go | 11 +++-------- sessionctx/variable/sysvar.go | 5 +---- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/executor/set_test.go b/executor/set_test.go index 9be1f1794ce1c..6b166059e6921 100644 --- a/executor/set_test.go +++ b/executor/set_test.go @@ -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")) diff --git a/sessionctx/variable/sysvar.go b/sessionctx/variable/sysvar.go index 60543c00d334e..fc7ce09cae6a7 100644 --- a/sessionctx/variable/sysvar.go +++ b/sessionctx/variable/sysvar.go @@ -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))