From 028f63cb4ab40ff1a7ebe47714f7fd9399a98da0 Mon Sep 17 00:00:00 2001 From: Jack Yu Date: Wed, 7 Aug 2019 15:04:56 +0800 Subject: [PATCH] *: rename tidb_back_off_weight (#11655) --- executor/set_test.go | 16 ++++++++-------- session/bootstrap.go | 11 +++++++++++ session/session.go | 2 +- session/session_test.go | 2 +- sessionctx/variable/tidb_vars.go | 4 ++-- 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/executor/set_test.go b/executor/set_test.go index fb370b1e85..6fefbdadc1 100644 --- a/executor/set_test.go +++ b/executor/set_test.go @@ -370,16 +370,16 @@ func (s *testSuite2) TestSetVar(c *C) { c.Assert(err.Error(), Equals, "tidb_wait_split_region_timeout(0) cannot be smaller than 1") tk.MustQuery(`select @@session.tidb_wait_split_region_timeout;`).Check(testkit.Rows("1")) - tk.MustExec("set session tidb_back_off_weight = 3") - tk.MustQuery("select @@session.tidb_back_off_weight;").Check(testkit.Rows("3")) - tk.MustExec("set session tidb_back_off_weight = 20") - tk.MustQuery("select @@session.tidb_back_off_weight;").Check(testkit.Rows("20")) - _, err = tk.Exec("set session tidb_back_off_weight = -1") + tk.MustExec("set session tidb_backoff_weight = 3") + tk.MustQuery("select @@session.tidb_backoff_weight;").Check(testkit.Rows("3")) + tk.MustExec("set session tidb_backoff_weight = 20") + tk.MustQuery("select @@session.tidb_backoff_weight;").Check(testkit.Rows("20")) + _, err = tk.Exec("set session tidb_backoff_weight = -1") c.Assert(err, NotNil) - _, err = tk.Exec("set global tidb_back_off_weight = 0") + _, err = tk.Exec("set global tidb_backoff_weight = 0") c.Assert(err, NotNil) - tk.MustExec("set global tidb_back_off_weight = 10") - tk.MustQuery("select @@global.tidb_back_off_weight;").Check(testkit.Rows("10")) + tk.MustExec("set global tidb_backoff_weight = 10") + tk.MustQuery("select @@global.tidb_backoff_weight;").Check(testkit.Rows("10")) tk.MustExec("set @@tidb_expensive_query_time_threshold=70") tk.MustQuery("select @@tidb_expensive_query_time_threshold;").Check(testkit.Rows("70")) diff --git a/session/bootstrap.go b/session/bootstrap.go index dca15445ed..b9ed24428b 100644 --- a/session/bootstrap.go +++ b/session/bootstrap.go @@ -348,6 +348,7 @@ const ( version32 = 32 version33 = 33 version34 = 34 + version35 = 35 ) func checkBootstrapped(s Session) (bool, error) { @@ -543,6 +544,10 @@ func upgrade(s Session) { upgradeToVer34(s) } + if ver < version35 { + upgradeToVer35(s) + } + updateBootstrapVer(s) _, err = s.Execute(context.Background(), "COMMIT") @@ -853,6 +858,12 @@ func upgradeToVer34(s Session) { doReentrantDDL(s, CreateOptRuleBlacklist) } +func upgradeToVer35(s Session) { + sql := fmt.Sprintf("UPDATE HIGH_PRIORITY %s.%s SET VARIABLE_NAME = '%s' WHERE VARIABLE_NAME = 'tidb_back_off_weight'", + mysql.SystemDB, mysql.GlobalVariablesTable, variable.TiDBBackOffWeight) + mustExecute(s, sql) +} + // updateBootstrapVer updates bootstrap version variable in mysql.TiDB table. func updateBootstrapVer(s Session) { // Update bootstrap version. diff --git a/session/session.go b/session/session.go index 236c78955e..4ab10550ed 100644 --- a/session/session.go +++ b/session/session.go @@ -1641,7 +1641,7 @@ func createSessionWithDomain(store kv.Storage, dom *domain.Domain) (*session, er const ( notBootstrapped = 0 - currentBootstrapVersion = 34 + currentBootstrapVersion = 35 ) func getStoreBootstrapVersion(store kv.Storage) int64 { diff --git a/session/session_test.go b/session/session_test.go index e7c01d368c..5973742d41 100644 --- a/session/session_test.go +++ b/session/session_test.go @@ -2419,7 +2419,7 @@ func (s *testSessionSuite) TestKVVars(c *C) { tk.MustExec("insert kvvars values (1, 1)") tk2 := testkit.NewTestKitWithInit(c, s.store) tk2.MustExec("set @@tidb_backoff_lock_fast = 1") - tk2.MustExec("set @@tidb_back_off_weight = 100") + tk2.MustExec("set @@tidb_backoff_weight = 100") backoffVal := new(int64) backOffWeightVal := new(int32) tk2.Se.GetSessionVars().KVVars.Hook = func(name string, vars *kv.Variables) { diff --git a/sessionctx/variable/tidb_vars.go b/sessionctx/variable/tidb_vars.go index f2b7998ab0..ade964cb85 100644 --- a/sessionctx/variable/tidb_vars.go +++ b/sessionctx/variable/tidb_vars.go @@ -225,11 +225,11 @@ const ( // tidb_backoff_lock_fast is used for tikv backoff base time in milliseconds. TiDBBackoffLockFast = "tidb_backoff_lock_fast" - // tidb_back_off_weight is used to control the max back off time in TiDB. + // tidb_backoff_weight is used to control the max back off time in TiDB. // The default maximum back off time is a small value. // BackOffWeight could multiply it to let the user adjust the maximum time for retrying. // Only positive integers can be accepted, which means that the maximum back off time can only grow. - TiDBBackOffWeight = "tidb_back_off_weight" + TiDBBackOffWeight = "tidb_backoff_weight" // tidb_ddl_reorg_worker_cnt defines the count of ddl reorg workers. TiDBDDLReorgWorkerCount = "tidb_ddl_reorg_worker_cnt"