From 44dca839e15340ae2bc2ac18e78e86b3f8796b10 Mon Sep 17 00:00:00 2001 From: Shuaipeng Yu Date: Wed, 7 Aug 2019 13:24:21 +0800 Subject: [PATCH 1/4] *: rename tidb_back_off_weight Signed-off-by: Shuaipeng Yu --- CHANGELOG.md | 4 ++-- executor/set_test.go | 16 ++++++++-------- session/session_test.go | 2 +- sessionctx/variable/tidb_vars.go | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ff200de38df0..f92456ec7be36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -107,7 +107,7 @@ All notable changes to this project will be documented in this file. See also [R * Optimize the system initialization process to only allow the DDL owner to perform the initialization. This reduces the startup time for initialization or upgrading. * Optimize the execution logic of `kill query` to improve performance and ensure resource is release properly * Add a startup option `config-check` to check the validity of the configuration file -* Add the `tidb_back_off_weight` system variable to control the backoff time of internal error retries +* Add the `tidb_backoff_weight` system variable to control the backoff time of internal error retries * Add the `wait_timeout`and `interactive_timeout` system variables to control the maximum idle connections allowed * Add the connection pool for TiKV to shorten the connection establishing time @@ -227,7 +227,7 @@ All notable changes to this project will be documented in this file. See also [R Fix the issue that TiDB continuously creates a new connection to TiKV when a fault occurs in TiKV [#10301](https://github.com/pingcap/tidb/pull/10301) Make `tidb_disable_txn_auto_retry` affect all retryable errors instead of only write conflict errors [#10339](https://github.com/pingcap/tidb/pull/10339) Allow DDL statements without parameters to be executed using `prepare`/`execute` [#10144](https://github.com/pingcap/tidb/pull/10144) -Add the `tidb_back_off_weight` variable to control the backoff time [#10266](https://github.com/pingcap/tidb/pull/10266) +Add the `tidb_backoff_weight` variable to control the backoff time [#10266](https://github.com/pingcap/tidb/pull/10266) Prohibit TiDB retrying non-automatically committed transactions in default conditions by setting the default value of `tidb_disable_txn_auto_retry` to `on` [#10266](https://github.com/pingcap/tidb/pull/10266) Fix the database privilege judgment of `role` in `RBAC` [#10261](https://github.com/pingcap/tidb/pull/10261) Support the pessimistic transaction model (experimental) [#10297](https://github.com/pingcap/tidb/pull/10297) diff --git a/executor/set_test.go b/executor/set_test.go index fb370b1e855da..6fefbdadc10b0 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/session_test.go b/session/session_test.go index e7c01d368c0ce..5973742d411c6 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 f2b7998ab0341..ade964cb85966 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" From fd400ed1c8f0e44a6d74a82769f2fe00e55884d0 Mon Sep 17 00:00:00 2001 From: Shuaipeng Yu Date: Wed, 7 Aug 2019 13:31:37 +0800 Subject: [PATCH 2/4] revert unrelated changes Signed-off-by: Shuaipeng Yu --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f92456ec7be36..2ff200de38df0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -107,7 +107,7 @@ All notable changes to this project will be documented in this file. See also [R * Optimize the system initialization process to only allow the DDL owner to perform the initialization. This reduces the startup time for initialization or upgrading. * Optimize the execution logic of `kill query` to improve performance and ensure resource is release properly * Add a startup option `config-check` to check the validity of the configuration file -* Add the `tidb_backoff_weight` system variable to control the backoff time of internal error retries +* Add the `tidb_back_off_weight` system variable to control the backoff time of internal error retries * Add the `wait_timeout`and `interactive_timeout` system variables to control the maximum idle connections allowed * Add the connection pool for TiKV to shorten the connection establishing time @@ -227,7 +227,7 @@ All notable changes to this project will be documented in this file. See also [R Fix the issue that TiDB continuously creates a new connection to TiKV when a fault occurs in TiKV [#10301](https://github.com/pingcap/tidb/pull/10301) Make `tidb_disable_txn_auto_retry` affect all retryable errors instead of only write conflict errors [#10339](https://github.com/pingcap/tidb/pull/10339) Allow DDL statements without parameters to be executed using `prepare`/`execute` [#10144](https://github.com/pingcap/tidb/pull/10144) -Add the `tidb_backoff_weight` variable to control the backoff time [#10266](https://github.com/pingcap/tidb/pull/10266) +Add the `tidb_back_off_weight` variable to control the backoff time [#10266](https://github.com/pingcap/tidb/pull/10266) Prohibit TiDB retrying non-automatically committed transactions in default conditions by setting the default value of `tidb_disable_txn_auto_retry` to `on` [#10266](https://github.com/pingcap/tidb/pull/10266) Fix the database privilege judgment of `role` in `RBAC` [#10261](https://github.com/pingcap/tidb/pull/10261) Support the pessimistic transaction model (experimental) [#10297](https://github.com/pingcap/tidb/pull/10297) From 934f98a59a54c38cf8c7fa182653d130a2141d1a Mon Sep 17 00:00:00 2001 From: Shuaipeng Yu Date: Wed, 7 Aug 2019 13:57:48 +0800 Subject: [PATCH 3/4] add a upgrade function Signed-off-by: Shuaipeng Yu --- session/bootstrap.go | 9 +++++++++ session/session.go | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/session/bootstrap.go b/session/bootstrap.go index dca15445ed679..d092659d0bb1c 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,10 @@ func upgradeToVer34(s Session) { doReentrantDDL(s, CreateOptRuleBlacklist) } +func upgradeToVer35(s Session) { + mustExecute(s, "UPDATE HIGH_PRIORITY mysql.GLOBAL_VARIABLES SET VARIABLE_NAME='tidb_backoff_weight' WHERE VARIABLE_NAME='tidb_back_off_weight'") +} + // 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 236c78955e645..4ab10550ed299 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 { From 66961182dca42c21e7d65124f8dfa70f7477e4ea Mon Sep 17 00:00:00 2001 From: Shuaipeng Yu Date: Wed, 7 Aug 2019 14:29:25 +0800 Subject: [PATCH 4/4] format the SQL Signed-off-by: Shuaipeng Yu --- session/bootstrap.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/session/bootstrap.go b/session/bootstrap.go index d092659d0bb1c..b9ed24428bf55 100644 --- a/session/bootstrap.go +++ b/session/bootstrap.go @@ -859,7 +859,9 @@ func upgradeToVer34(s Session) { } func upgradeToVer35(s Session) { - mustExecute(s, "UPDATE HIGH_PRIORITY mysql.GLOBAL_VARIABLES SET VARIABLE_NAME='tidb_backoff_weight' WHERE VARIABLE_NAME='tidb_back_off_weight'") + 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.