From 39cc8935cdc9d06cf7838b11bdee6505def29bb9 Mon Sep 17 00:00:00 2001 From: "Zhuomin(Charming) Liu" Date: Thu, 16 Apr 2020 20:28:48 +0800 Subject: [PATCH] session: fix unseccessfully isolation read engines init session (#16465) --- tidb-server/main.go | 1 + tidb-server/main_test.go | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/tidb-server/main.go b/tidb-server/main.go index 3b179e9723..93fb498e30 100644 --- a/tidb-server/main.go +++ b/tidb-server/main.go @@ -568,6 +568,7 @@ func setGlobalVars() { variable.SysVars[variable.Socket].Value = cfg.Socket variable.SysVars[variable.DataDir].Value = cfg.Path variable.SysVars[variable.TiDBSlowQueryFile].Value = cfg.Log.SlowQueryFile + variable.SysVars[variable.TiDBIsolationReadEngines].Value = strings.Join(cfg.IsolationRead.Engines, ", ") // For CI environment we default enable prepare-plan-cache. plannercore.SetPreparedPlanCache(config.CheckTableBeforeDrop || cfg.PreparedPlanCache.Enabled) diff --git a/tidb-server/main_test.go b/tidb-server/main_test.go index 747b40505c..f745c75339 100644 --- a/tidb-server/main_test.go +++ b/tidb-server/main_test.go @@ -17,6 +17,8 @@ import ( "testing" . "github.com/pingcap/check" + "github.com/pingcap/tidb/config" + "github.com/pingcap/tidb/sessionctx/variable" ) var isCoverageServer = "0" @@ -32,3 +34,19 @@ func TestRunMain(t *testing.T) { func TestT(t *testing.T) { TestingT(t) } + +var _ = Suite(&testMainSuite{}) + +type testMainSuite struct{} + +func (t *testMainSuite) TestSetGlobalVars(c *C) { + c.Assert(variable.SysVars[variable.TiDBIsolationReadEngines].Value, Equals, "tikv, tiflash, tidb") + c.Assert(variable.SysVars[variable.TIDBMemQuotaQuery].Value, Equals, "1073741824") + + config.GetGlobalConfig().IsolationRead.Engines = []string{"tikv", "tidb"} + config.GetGlobalConfig().MemQuotaQuery = 9999999 + setGlobalVars() + + c.Assert(variable.SysVars[variable.TiDBIsolationReadEngines].Value, Equals, "tikv, tidb") + c.Assert(variable.SysVars[variable.TIDBMemQuotaQuery].Value, Equals, "9999999") +}