Skip to content

Commit

Permalink
session: fix unseccessfully isolation read engines init session (#16465
Browse files Browse the repository at this point in the history
…) (#16482)
  • Loading branch information
sre-bot authored Apr 26, 2020
1 parent 8fef6bb commit 6f49324
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
1 change: 0 additions & 1 deletion sessionctx/variable/sysvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,6 @@ var defaultSysVars = []*SysVar{
{ScopeGlobal | ScopeSession, TiDBStmtSummaryHistorySize, strconv.Itoa(config.GetGlobalConfig().StmtSummary.HistorySize)},
{ScopeSession, TiDBIsolationReadEngines, strings.Join(config.GetGlobalConfig().IsolationRead.Engines, ", ")},
{ScopeGlobal | ScopeSession, TiDBStoreLimit, strconv.FormatInt(atomic.LoadInt64(&config.GetGlobalConfig().TiKVClient.StoreLimit), 10)},
{ScopeGlobal | ScopeSession, TiDBIsolationReadEngines, "tikv,tiflash"},
}

// SynonymsSysVariables is synonyms of system variables.
Expand Down
2 changes: 2 additions & 0 deletions tidb-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"os"
"runtime"
"strconv"
"strings"
"sync/atomic"
"time"

Expand Down Expand Up @@ -517,6 +518,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)
Expand Down
29 changes: 28 additions & 1 deletion tidb-server/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@

package main

import "testing"
import (
"testing"

. "github.com/pingcap/check"
"github.com/pingcap/tidb/config"
"github.com/pingcap/tidb/sessionctx/variable"
)

var isCoverageServer = "0"

Expand All @@ -24,3 +30,24 @@ func TestRunMain(t *testing.T) {
main()
}
}

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")
c.Assert(variable.SysVars[variable.TIDBMemQuotaQuery].Value, Equals, "34359738368")

loadConfig()
config.GetGlobalConfig().IsolationRead.Engines = []string{"tikv"}
config.GetGlobalConfig().MemQuotaQuery = 9999999
setGlobalVars()

c.Assert(variable.SysVars[variable.TiDBIsolationReadEngines].Value, Equals, "tikv")
c.Assert(variable.SysVars[variable.TIDBMemQuotaQuery].Value, Equals, "9999999")
}

0 comments on commit 6f49324

Please sign in to comment.