Skip to content
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

session: fix unseccessfully isolation read engines init session (#16465) #16482

Merged
merged 8 commits into from
Apr 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
}