From 866c5514afeb456c687ae9dc9444df4eb08cb841 Mon Sep 17 00:00:00 2001 From: Morgan Tocker Date: Sun, 19 Dec 2021 08:21:45 -0600 Subject: [PATCH] session: fix bootstrap to only persist global variables (#30593) close pingcap/tidb#28667 --- session/bootstrap.go | 4 ++-- session/bootstrap_serial_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/session/bootstrap.go b/session/bootstrap.go index 2244e3eaa5484..e5c588ec5af01 100644 --- a/session/bootstrap.go +++ b/session/bootstrap.go @@ -1764,8 +1764,8 @@ func doDMLWorks(s Session) { // Init global system variables table. values := make([]string, 0, len(variable.GetSysVars())) for k, v := range variable.GetSysVars() { - // Session only variable should not be inserted. - if v.Scope != variable.ScopeSession { + // Only global variables should be inserted. + if v.HasGlobalScope() { vVal := v.Value if v.Name == variable.TiDBTxnMode && config.GetGlobalConfig().Store == "tikv" { vVal = "pessimistic" diff --git a/session/bootstrap_serial_test.go b/session/bootstrap_serial_test.go index 1de04a5ca91f3..6caf7e702c10b 100644 --- a/session/bootstrap_serial_test.go +++ b/session/bootstrap_serial_test.go @@ -113,7 +113,7 @@ func TestBootstrap(t *testing.T) { func globalVarsCount() int64 { var count int64 for _, v := range variable.GetSysVars() { - if v.Scope != variable.ScopeSession { + if v.HasGlobalScope() { count++ } }