Skip to content

Commit

Permalink
*: rename tidb_back_off_weight (#11655) (#11665)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackysp authored Aug 8, 2019
1 parent eca09b1 commit b066cba
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
16 changes: 8 additions & 8 deletions executor/set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,16 +368,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"))
Expand Down
11 changes: 11 additions & 0 deletions session/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ const (
version32 = 32
version33 = 33
version34 = 34
version35 = 35
)

func checkBootstrapped(s Session) (bool, error) {
Expand Down Expand Up @@ -543,6 +544,10 @@ func upgrade(s Session) {
upgradeToVer34(s)
}

if ver < version35 {
upgradeToVer35(s)
}

updateBootstrapVer(s)
_, err = s.Execute(context.Background(), "COMMIT")

Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -1600,7 +1600,7 @@ func createSessionWithDomain(store kv.Storage, dom *domain.Domain) (*session, er

const (
notBootstrapped = 0
currentBootstrapVersion = 34
currentBootstrapVersion = 35
)

func getStoreBootstrapVersion(store kv.Storage) int64 {
Expand Down
2 changes: 1 addition & 1 deletion session/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2345,7 +2345,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) {
Expand Down
4 changes: 2 additions & 2 deletions sessionctx/variable/tidb_vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit b066cba

Please sign in to comment.