From c5b7658b089655ee203de97b770e1e0a00849eaa Mon Sep 17 00:00:00 2001 From: Neil Shen Date: Thu, 20 Aug 2020 17:28:36 +0800 Subject: [PATCH] *: cherry-pick #17964 and update pd to v4.0.4 (#19105) * test: fix data race caused by update global config (#17964) Co-authored-by: pingcap-github-bot Signed-off-by: Neil Shen * fix make dev Signed-off-by: Neil Shen * update kvproto and pd Signed-off-by: Neil Shen Co-authored-by: Evan Zhou Co-authored-by: pingcap-github-bot --- config/config.go | 16 +++++++ ddl/db_change_test.go | 8 +++- ddl/db_integration_test.go | 41 +++++++++++----- ddl/db_test.go | 12 +++-- ddl/ddl_test.go | 15 +++--- ddl/serial_test.go | 61 ++++++++++------------- executor/executor_pkg_test.go | 11 ++--- executor/executor_test.go | 38 ++++++--------- executor/infoschema_reader_test.go | 13 +++-- executor/join_test.go | 9 ++-- executor/merge_join_test.go | 14 +++--- executor/oomtest/oom_test.go | 7 ++- executor/seqtest/seq_executor_test.go | 22 ++++----- executor/simple_test.go | 10 ++-- executor/sort_test.go | 9 ++-- executor/statement_context_test.go | 13 +++-- executor/write_concurrent_test.go | 11 ++--- go.mod | 19 +++++--- go.sum | 69 +++++++++++++++++++++++++++ infoschema/tables_test.go | 6 +-- planner/core/cbo_test.go | 12 ++--- planner/core/integration_test.go | 6 ++- session/session_test.go | 37 +++++++------- sessionctx/variable/session_test.go | 9 ++-- store/mockstore/mocktikv/pd.go | 6 +-- store/mockstore/tikv_test.go | 20 ++++---- store/tikv/region_request_test.go | 24 ---------- store/tikv/store_test.go | 6 +-- tidb-server/main_test.go | 7 +-- util/chunk/chunk_test.go | 12 ++--- 30 files changed, 301 insertions(+), 242 deletions(-) diff --git a/config/config.go b/config/config.go index 24d0cf543ee74..34e88fe13e3e1 100644 --- a/config/config.go +++ b/config/config.go @@ -887,6 +887,22 @@ func (c *Config) Valid() error { return l.UnmarshalText([]byte(c.Log.Level)) } +// UpdateGlobal updates the global config, and provide a restore function that can be used to restore to the original. +func UpdateGlobal(f func(conf *Config)) { + g := GetGlobalConfig() + newConf := *g + f(&newConf) + StoreGlobalConfig(&newConf) +} + +// RestoreFunc gets a function that restore the config to the current value. +func RestoreFunc() (restore func()) { + g := GetGlobalConfig() + return func() { + StoreGlobalConfig(g) + } +} + func hasRootPrivilege() bool { return os.Geteuid() == 0 } diff --git a/ddl/db_change_test.go b/ddl/db_change_test.go index 8bd537b5714c9..f7a345f3b9016 100644 --- a/ddl/db_change_test.go +++ b/ddl/db_change_test.go @@ -92,7 +92,9 @@ func (s *testStateChangeSuiteBase) TearDownSuite(c *C) { // TestShowCreateTable tests the result of "show create table" when we are running "add index" or "add column". func (s *serialTestStateChangeSuite) TestShowCreateTable(c *C) { - config.GetGlobalConfig().Experimental.AllowsExpressionIndex = true + config.UpdateGlobal(func(conf *config.Config) { + conf.Experimental.AllowsExpressionIndex = true + }) tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test") tk.MustExec("create table t (id int)") @@ -807,7 +809,9 @@ func (s *testStateChangeSuite) TestParallelAlterAddIndex(c *C) { } func (s *serialTestStateChangeSuite) TestParallelAlterAddExpressionIndex(c *C) { - config.GetGlobalConfig().Experimental.AllowsExpressionIndex = true + config.UpdateGlobal(func(conf *config.Config) { + conf.Experimental.AllowsExpressionIndex = true + }) sql1 := "ALTER TABLE t add index expr_index_b((b+1));" sql2 := "CREATE INDEX expr_index_b ON t ((c+1));" f := func(c *C, err1, err2 error) { diff --git a/ddl/db_integration_test.go b/ddl/db_integration_test.go index 03eff83dc2c42..6faf741ec2430 100644 --- a/ddl/db_integration_test.go +++ b/ddl/db_integration_test.go @@ -1614,8 +1614,9 @@ func (s *testIntegrationSuite1) TestTreatOldVersionUTF8AsUTF8MB4(c *C) { " `b` varchar(10) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL,\n" + " `c` varchar(10) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL\n" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin")) - - config.GetGlobalConfig().TreatOldVersionUTF8AsUTF8MB4 = false + config.UpdateGlobal(func(conf *config.Config) { + conf.TreatOldVersionUTF8AsUTF8MB4 = false + }) s.tk.MustExec("alter table t drop column c;") // reload schema. s.tk.MustGetErrCode("insert into t set a= x'f09f8c80'", errno.ErrTruncatedWrongValueForField) s.tk.MustQuery("show create table t").Check(testkit.Rows("t CREATE TABLE `t` (\n" + @@ -1632,7 +1633,9 @@ func (s *testIntegrationSuite1) TestTreatOldVersionUTF8AsUTF8MB4(c *C) { tblInfo.Columns[0].Version = model.ColumnInfoVersion0 updateTableInfo(tblInfo) - config.GetGlobalConfig().TreatOldVersionUTF8AsUTF8MB4 = true + config.UpdateGlobal(func(conf *config.Config) { + conf.TreatOldVersionUTF8AsUTF8MB4 = true + }) s.tk.MustExec("alter table t add column c varchar(10);") // load latest schema. s.tk.MustExec("insert into t set a= x'f09f8c80'") s.tk.MustQuery("show create table t").Check(testkit.Rows("t CREATE TABLE `t` (\n" + @@ -1641,7 +1644,9 @@ func (s *testIntegrationSuite1) TestTreatOldVersionUTF8AsUTF8MB4(c *C) { " `c` varchar(10) DEFAULT NULL\n" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin")) - config.GetGlobalConfig().TreatOldVersionUTF8AsUTF8MB4 = false + config.UpdateGlobal(func(conf *config.Config) { + conf.TreatOldVersionUTF8AsUTF8MB4 = false + }) s.tk.MustExec("alter table t drop column c;") // reload schema. s.tk.MustGetErrCode("insert into t set a= x'f09f8c80'", errno.ErrTruncatedWrongValueForField) s.tk.MustQuery("show create table t").Check(testkit.Rows("t CREATE TABLE `t` (\n" + @@ -1650,7 +1655,9 @@ func (s *testIntegrationSuite1) TestTreatOldVersionUTF8AsUTF8MB4(c *C) { ") ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")) // Test modify column charset. - config.GetGlobalConfig().TreatOldVersionUTF8AsUTF8MB4 = true + config.UpdateGlobal(func(conf *config.Config) { + conf.TreatOldVersionUTF8AsUTF8MB4 = true + }) s.tk.MustExec("alter table t modify column a varchar(10) character set utf8mb4") // change column charset. tbl = testGetTableByName(c, s.ctx, "test", "t") c.Assert(tbl.Meta().Columns[0].Charset, Equals, charset.CharsetUTF8MB4) @@ -1686,7 +1693,9 @@ func (s *testIntegrationSuite1) TestTreatOldVersionUTF8AsUTF8MB4(c *C) { " `b` varchar(20) CHARACTER SET ascii COLLATE ascii_bin DEFAULT NULL\n" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin")) - config.GetGlobalConfig().TreatOldVersionUTF8AsUTF8MB4 = false + config.UpdateGlobal(func(conf *config.Config) { + conf.TreatOldVersionUTF8AsUTF8MB4 = false + }) s.tk.MustExec("alter table t change column b b varchar(30) character set ascii") // reload schema. s.tk.MustGetErrCode("insert into t set a= x'f09f8c80'", errno.ErrTruncatedWrongValueForField) s.tk.MustQuery("show create table t").Check(testkit.Rows("t CREATE TABLE `t` (\n" + @@ -1695,11 +1704,15 @@ func (s *testIntegrationSuite1) TestTreatOldVersionUTF8AsUTF8MB4(c *C) { ") ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin")) // Test for alter table convert charset - config.GetGlobalConfig().TreatOldVersionUTF8AsUTF8MB4 = true + config.UpdateGlobal(func(conf *config.Config) { + conf.TreatOldVersionUTF8AsUTF8MB4 = true + }) s.tk.MustExec("alter table t drop column b") // reload schema. s.tk.MustExec("alter table t convert to charset utf8mb4;") - config.GetGlobalConfig().TreatOldVersionUTF8AsUTF8MB4 = false + config.UpdateGlobal(func(conf *config.Config) { + conf.TreatOldVersionUTF8AsUTF8MB4 = false + }) s.tk.MustExec("alter table t add column b varchar(50);") // reload schema. s.tk.MustQuery("show create table t").Check(testkit.Rows("t CREATE TABLE `t` (\n" + " `a` varchar(20) DEFAULT NULL,\n" + @@ -1953,7 +1966,9 @@ func (s *testIntegrationSuite3) TestParserIssue284(c *C) { } func (s *testIntegrationSuite7) TestAddExpressionIndex(c *C) { - config.GetGlobalConfig().Experimental.AllowsExpressionIndex = true + config.UpdateGlobal(func(conf *config.Config) { + conf.Experimental.AllowsExpressionIndex = true + }) tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test") tk.MustExec("drop table if exists t;") @@ -1999,12 +2014,16 @@ func (s *testIntegrationSuite7) TestAddExpressionIndex(c *C) { tk.MustQuery("select * from t;").Check(testkit.Rows("1 2.1")) // Test experiment switch. - config.GetGlobalConfig().Experimental.AllowsExpressionIndex = false + config.UpdateGlobal(func(conf *config.Config) { + conf.Experimental.AllowsExpressionIndex = false + }) tk.MustGetErrMsg("create index d on t((a+1))", "[ddl:8200]Unsupported creating expression index without allow-expression-index in config") } func (s *testIntegrationSuite7) TestCreateExpressionIndexError(c *C) { - config.GetGlobalConfig().Experimental.AllowsExpressionIndex = true + config.UpdateGlobal(func(conf *config.Config) { + conf.Experimental.AllowsExpressionIndex = true + }) tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test") diff --git a/ddl/db_test.go b/ddl/db_test.go index fc94cec089990..2a252c24edcfb 100644 --- a/ddl/db_test.go +++ b/ddl/db_test.go @@ -293,7 +293,9 @@ func (s *testDBSuite2) TestAddUniqueIndexRollback(c *C) { } func (s *testSerialDBSuite) TestAddExpressionIndexRollback(c *C) { - config.GetGlobalConfig().Experimental.AllowsExpressionIndex = true + config.UpdateGlobal(func(conf *config.Config) { + conf.Experimental.AllowsExpressionIndex = true + }) tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test_db") tk.MustExec("drop table if exists t1") @@ -4418,7 +4420,9 @@ func (s *testDBSuite2) TestTablesLockDelayClean(c *C) { tk.MustExec("lock tables t1 write") checkTableLock(c, tk.Se, "test", "t1", model.TableLockWrite) - config.GetGlobalConfig().DelayCleanTableLock = 100 + config.UpdateGlobal(func(conf *config.Config) { + conf.DelayCleanTableLock = 100 + }) var wg sync.WaitGroup wg.Add(1) var startTime time.Time @@ -4432,7 +4436,9 @@ func (s *testDBSuite2) TestTablesLockDelayClean(c *C) { wg.Wait() c.Assert(time.Since(startTime).Seconds() > 0.1, IsTrue) checkTableLock(c, tk.Se, "test", "t1", model.TableLockNone) - config.GetGlobalConfig().DelayCleanTableLock = 0 + config.UpdateGlobal(func(conf *config.Config) { + conf.DelayCleanTableLock = 0 + }) } // TestConcurrentLockTables test concurrent lock/unlock tables. diff --git a/ddl/ddl_test.go b/ddl/ddl_test.go index 8ae843e6c4673..b26720468e328 100644 --- a/ddl/ddl_test.go +++ b/ddl/ddl_test.go @@ -94,14 +94,13 @@ func TestT(t *testing.T) { ReorgWaitTimeout = 30 * time.Millisecond batchInsertDeleteRangeSize = 2 - cfg := config.GetGlobalConfig() - newCfg := *cfg - // Test for table lock. - newCfg.EnableTableLock = true - newCfg.Log.SlowThreshold = 10000 - // Test for add/drop primary key. - newCfg.AlterPrimaryKey = true - config.StoreGlobalConfig(&newCfg) + config.UpdateGlobal(func(conf *config.Config) { + // Test for table lock. + conf.EnableTableLock = true + conf.Log.SlowThreshold = 10000 + // Test for add/drop primary key. + conf.AlterPrimaryKey = true + }) testleak.BeforeTest() TestingT(t) diff --git a/ddl/serial_test.go b/ddl/serial_test.go index 46c7e207633c2..7e9c2c4b3b991 100644 --- a/ddl/serial_test.go +++ b/ddl/serial_test.go @@ -61,12 +61,10 @@ type testSerialSuite struct { func (s *testSerialSuite) SetUpSuite(c *C) { session.SetSchemaLease(200 * time.Millisecond) session.DisableStats4Test() - - cfg := config.GetGlobalConfig() - newCfg := *cfg - // Test for add/drop primary key. - newCfg.AlterPrimaryKey = false - config.StoreGlobalConfig(&newCfg) + config.UpdateGlobal(func(conf *config.Config) { + // Test for add/drop primary key. + conf.AlterPrimaryKey = false + }) ddl.SetWaitTimeWhenErrorOccurred(1 * time.Microsecond) var err error @@ -88,15 +86,11 @@ func (s *testSerialSuite) TearDownSuite(c *C) { func (s *testSerialSuite) TestChangeMaxIndexLength(c *C) { tk := testkit.NewTestKitWithInit(c, s.store) - cfg := config.GetGlobalConfig() - newCfg := *cfg - originalMaxIndexLen := cfg.MaxIndexLength - newCfg.MaxIndexLength = config.DefMaxOfMaxIndexLength - config.StoreGlobalConfig(&newCfg) - defer func() { - newCfg.MaxIndexLength = originalMaxIndexLen - config.StoreGlobalConfig(&newCfg) - }() + + defer config.RestoreFunc()() + config.UpdateGlobal(func(conf *config.Config) { + conf.MaxIndexLength = config.DefMaxOfMaxIndexLength + }) tk.MustExec("create table t (c1 varchar(3073), index(c1)) charset = ascii;") tk.MustExec(fmt.Sprintf("create table t1 (c1 varchar(%d), index(c1)) charset = ascii;", config.DefMaxOfMaxIndexLength)) @@ -125,15 +119,10 @@ func (s *testSerialSuite) TestPrimaryKey(c *C) { tk.MustExec("create table primary_key_test1 (a int, b varchar(10), primary key(a))") tk.MustExec("create table primary_key_test2 (a int, b varchar(10), primary key(b))") tk.MustExec("create table primary_key_test3 (a int, b varchar(10))") - cfg := config.GetGlobalConfig() - newCfg := *cfg - orignalAlterPrimaryKey := newCfg.AlterPrimaryKey - newCfg.AlterPrimaryKey = true - config.StoreGlobalConfig(&newCfg) - defer func() { - newCfg.AlterPrimaryKey = orignalAlterPrimaryKey - config.StoreGlobalConfig(&newCfg) - }() + defer config.RestoreFunc()() + config.UpdateGlobal(func(conf *config.Config) { + conf.AlterPrimaryKey = true + }) _, err = tk.Exec("alter table primary_key_test2 add primary key(a)") c.Assert(infoschema.ErrMultiplePriKey.Equal(err), IsTrue) @@ -151,8 +140,9 @@ func (s *testSerialSuite) TestPrimaryKey(c *C) { // for "drop index `primary` on ..." syntax tk.MustExec("create table primary_key_test4 (a int, b varchar(10), primary key(a))") - newCfg.AlterPrimaryKey = false - config.StoreGlobalConfig(&newCfg) + config.UpdateGlobal(func(conf *config.Config) { + conf.AlterPrimaryKey = false + }) _, err = tk.Exec("drop index `primary` on primary_key_test4") c.Assert(err.Error(), Equals, "[ddl:8200]Unsupported drop primary key when alter-primary-key is false") // for the index name is `primary` @@ -812,13 +802,10 @@ func (s *testSerialSuite) TestTableLocksEnable(c *C) { tk.MustExec("create table t1 (a int)") // Test for enable table lock config. - cfg := config.GetGlobalConfig() - newCfg := *cfg - newCfg.EnableTableLock = false - config.StoreGlobalConfig(&newCfg) - defer func() { - config.StoreGlobalConfig(cfg) - }() + defer config.RestoreFunc()() + config.UpdateGlobal(func(conf *config.Config) { + conf.EnableTableLock = false + }) tk.MustExec("lock tables t1 write") checkTableLock(c, tk.Se, "test", "t1", model.TableLockNone) @@ -896,11 +883,15 @@ func (s *testSerialSuite) TestAutoRandom(c *C) { assertPKIsNotHandle("create table t (a bigint auto_random(3), b int, c char, primary key (a, c))", "a") // PKIsNotHandle: table is created when alter-primary-key = true. - config.GetGlobalConfig().AlterPrimaryKey = true + config.UpdateGlobal(func(conf *config.Config) { + conf.AlterPrimaryKey = true + }) assertPKIsNotHandle("create table t (a bigint auto_random(3) primary key, b int)", "a") assertPKIsNotHandle("create table t (a bigint auto_random(3) primary key, b int)", "a") assertPKIsNotHandle("create table t (a int, b bigint auto_random(3) primary key)", "b") - config.GetGlobalConfig().AlterPrimaryKey = false + config.UpdateGlobal(func(conf *config.Config) { + conf.AlterPrimaryKey = false + }) // Can not set auto_random along with auto_increment. assertWithAutoInc("create table t (a bigint auto_random(3) primary key auto_increment)") diff --git a/executor/executor_pkg_test.go b/executor/executor_pkg_test.go index 866ae605db861..6232bbeb910b9 100644 --- a/executor/executor_pkg_test.go +++ b/executor/executor_pkg_test.go @@ -256,12 +256,11 @@ func assertEqualStrings(c *C, got []field, expect []string) { } func (s *testExecSerialSuite) TestSortSpillDisk(c *C) { - originCfg := config.GetGlobalConfig() - newConf := *originCfg - newConf.OOMUseTmpStorage = true - newConf.MemQuotaQuery = 1 - config.StoreGlobalConfig(&newConf) - defer config.StoreGlobalConfig(originCfg) + defer config.RestoreFunc()() + config.UpdateGlobal(func(conf *config.Config) { + conf.OOMUseTmpStorage = true + conf.MemQuotaQuery = 1 + }) c.Assert(failpoint.Enable("github.com/pingcap/tidb/executor/testSortedRowContainerSpill", "return(true)"), IsNil) defer func() { diff --git a/executor/executor_test.go b/executor/executor_test.go index 4cfceadd2b557..809e29a909d7b 100644 --- a/executor/executor_test.go +++ b/executor/executor_test.go @@ -86,11 +86,10 @@ func TestT(t *testing.T) { logutil.InitLogger(logutil.NewLogConfig(logLevel, logutil.DefaultLogFormat, "", logutil.EmptyFileLogConfig, false)) autoid.SetStep(5000) - old := config.GetGlobalConfig() - new := *old - new.Log.SlowThreshold = 30000 // 30s - new.Experimental.AllowsExpressionIndex = true - config.StoreGlobalConfig(&new) + config.UpdateGlobal(func(conf *config.Config) { + conf.Log.SlowThreshold = 30000 // 30s + conf.Experimental.AllowsExpressionIndex = true + }) tmpDir := config.GetGlobalConfig().TempStoragePath _ = os.RemoveAll(tmpDir) // clean the uncleared temp file during the last run. _ = os.MkdirAll(tmpDir, 0755) @@ -166,10 +165,9 @@ func (s *baseTestSuite) SetUpSuite(c *C) { c.Assert(err, IsNil) d.SetStatsUpdating(true) s.domain = d - originCfg := config.GetGlobalConfig() - newConf := *originCfg - newConf.OOMAction = config.OOMActionLog - config.StoreGlobalConfig(&newConf) + config.UpdateGlobal(func(conf *config.Config) { + conf.OOMAction = config.OOMActionLog + }) } func (s *baseTestSuite) TearDownSuite(c *C) { @@ -4680,11 +4678,10 @@ func (s *testSuite) TestOOMPanicAction(c *C) { } tk.Se.SetSessionManager(sm) s.domain.ExpensiveQueryHandle().SetSessionManager(sm) - orgAction := config.GetGlobalConfig().OOMAction - setOOMAction(config.OOMActionCancel) - defer func() { - setOOMAction(orgAction) - }() + defer config.RestoreFunc()() + config.UpdateGlobal(func(conf *config.Config) { + conf.OOMAction = config.OOMActionCancel + }) tk.MustExec("set @@tidb_mem_quota_query=1;") err := tk.QueryToErr("select sum(b) from t group by a;") c.Assert(err, NotNil) @@ -4732,13 +4729,6 @@ func (s *testSuite) TestOOMPanicAction(c *C) { c.Assert(err.Error(), Matches, "Out Of Memory Quota!.*") } -func setOOMAction(action string) { - old := config.GetGlobalConfig() - newConf := *old - newConf.OOMAction = action - config.StoreGlobalConfig(&newConf) -} - type testRecoverTable struct { store kv.Storage dom *domain.Domain @@ -5474,9 +5464,9 @@ func (s *testClusterTableSuite) setUpRPCService(c *C, addr string) (*grpc.Server err = srv.Serve(lis) c.Assert(err, IsNil) }() - cfg := config.GetGlobalConfig() - cfg.Status.StatusPort = uint(port) - config.StoreGlobalConfig(cfg) + config.UpdateGlobal(func(conf *config.Config) { + conf.Status.StatusPort = uint(port) + }) return srv, addr } func (s *testClusterTableSuite) TearDownSuite(c *C) { diff --git a/executor/infoschema_reader_test.go b/executor/infoschema_reader_test.go index 4d975982e33ec..667bc51a3d68b 100644 --- a/executor/infoschema_reader_test.go +++ b/executor/infoschema_reader_test.go @@ -82,10 +82,9 @@ func (s *testInfoschemaTableSuiteBase) SetUpSuite(c *C) { c.Assert(err, IsNil) s.store = store s.dom = dom - originCfg := config.GetGlobalConfig() - newConf := *originCfg - newConf.OOMAction = config.OOMActionLog - config.StoreGlobalConfig(&newConf) + config.UpdateGlobal(func(conf *config.Config) { + conf.OOMAction = config.OOMActionLog + }) } func (s *testInfoschemaTableSuiteBase) TearDownSuite(c *C) { @@ -587,9 +586,9 @@ func (s *testInfoschemaClusterTableSuite) setUpRPCService(c *C, addr string) (*g err = srv.Serve(lis) c.Assert(err, IsNil) }() - cfg := config.GetGlobalConfig() - cfg.Status.StatusPort = uint(port) - config.StoreGlobalConfig(cfg) + config.UpdateGlobal(func(conf *config.Config) { + conf.Status.StatusPort = uint(port) + }) return srv, addr } diff --git a/executor/join_test.go b/executor/join_test.go index 98487c4d2ba80..2aa0ae2f6ec34 100644 --- a/executor/join_test.go +++ b/executor/join_test.go @@ -66,11 +66,10 @@ func (s *testSuiteJoin1) TestJoinPanic(c *C) { } func (s *testSuite) TestJoinInDisk(c *C) { - originCfg := config.GetGlobalConfig() - newConf := *originCfg - newConf.OOMUseTmpStorage = true - config.StoreGlobalConfig(&newConf) - defer config.StoreGlobalConfig(originCfg) + defer config.RestoreFunc()() + config.UpdateGlobal(func(conf *config.Config) { + conf.OOMUseTmpStorage = true + }) tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test") diff --git a/executor/merge_join_test.go b/executor/merge_join_test.go index 5890e351db144..e4f2b73573eee 100644 --- a/executor/merge_join_test.go +++ b/executor/merge_join_test.go @@ -16,10 +16,11 @@ package executor_test import ( "bytes" "fmt" - "github.com/pingcap/tidb/sessionctx/variable" "math/rand" "strings" + "github.com/pingcap/tidb/sessionctx/variable" + . "github.com/pingcap/check" "github.com/pingcap/failpoint" "github.com/pingcap/tidb/config" @@ -241,12 +242,11 @@ func checkPlanAndRun(tk *testkit.TestKit, c *C, plan string, sql string) *testki return tk.MustQuery(sql) } -func (s *testSerialSuite1) TestMergeJoinInDisk(c *C) { - originCfg := config.GetGlobalConfig() - newConf := *originCfg - newConf.OOMUseTmpStorage = true - config.StoreGlobalConfig(&newConf) - defer config.StoreGlobalConfig(originCfg) +func (s *testSuite2) TestMergeJoinInDisk(c *C) { + defer config.RestoreFunc()() + config.UpdateGlobal(func(conf *config.Config) { + conf.OOMUseTmpStorage = true + }) c.Assert(failpoint.Enable("github.com/pingcap/tidb/executor/testMergeJoinRowContainerSpill", "return(true)"), IsNil) defer func() { diff --git a/executor/oomtest/oom_test.go b/executor/oomtest/oom_test.go index 9f2e28e3efa1d..5038f12e2c2d4 100644 --- a/executor/oomtest/oom_test.go +++ b/executor/oomtest/oom_test.go @@ -50,10 +50,9 @@ func (s *testOOMSuite) SetUpSuite(c *C) { domain.RunAutoAnalyze = false s.do, err = session.BootstrapSession(s.store) c.Assert(err, IsNil) - originCfg := config.GetGlobalConfig() - newConf := *originCfg - newConf.OOMAction = config.OOMActionLog - config.StoreGlobalConfig(&newConf) + config.UpdateGlobal(func(conf *config.Config) { + conf.OOMAction = config.OOMActionLog + }) } func (s *testOOMSuite) TearDownSuite(c *C) { diff --git a/executor/seqtest/seq_executor_test.go b/executor/seqtest/seq_executor_test.go index 4badf19583785..36005cf19c782 100644 --- a/executor/seqtest/seq_executor_test.go +++ b/executor/seqtest/seq_executor_test.go @@ -175,7 +175,9 @@ func (s stats) Stats(vars *variable.SessionVars) (map[string]interface{}, error) } func (s *seqTestSuite) TestShow(c *C) { - config.GetGlobalConfig().Experimental.AllowsExpressionIndex = true + config.UpdateGlobal(func(conf *config.Config) { + conf.Experimental.AllowsExpressionIndex = true + }) tk := testkit.NewTestKit(c, s.store) tk.MustExec("use test") @@ -1010,13 +1012,10 @@ func (s *seqTestSuite) TestBatchInsertDelete(c *C) { r = tk.MustQuery("select count(*) from batch_insert;") r.Check(testkit.Rows("320")) - cfg := config.GetGlobalConfig() - newCfg := *cfg - newCfg.EnableBatchDML = true - config.StoreGlobalConfig(&newCfg) - defer func() { - config.StoreGlobalConfig(cfg) - }() + defer config.RestoreFunc()() + config.UpdateGlobal(func(conf *config.Config) { + conf.EnableBatchDML = true + }) // Change to batch inset mode and batch size to 50. tk.MustExec("set @@session.tidb_batch_insert=1;") @@ -1174,9 +1173,10 @@ func (s *seqTestSuite1) TestCoprocessorPriority(c *C) { // Insert some data to make sure plan build IndexLookup for t. tk.MustExec("insert into t values (1), (2)") - oldThreshold := config.GetGlobalConfig().Log.ExpensiveThreshold - config.GetGlobalConfig().Log.ExpensiveThreshold = 0 - defer func() { config.GetGlobalConfig().Log.ExpensiveThreshold = oldThreshold }() + defer config.RestoreFunc()() + config.UpdateGlobal(func(conf *config.Config) { + conf.Log.ExpensiveThreshold = 0 + }) cli.setCheckPriority(pb.CommandPri_High) tk.MustQuery("select id from t where id = 1") diff --git a/executor/simple_test.go b/executor/simple_test.go index 9fa668463f8f7..b01f5966e89c4 100644 --- a/executor/simple_test.go +++ b/executor/simple_test.go @@ -549,10 +549,10 @@ func (s *testFlushSuite) TestFlushPrivilegesPanic(c *C) { c.Assert(err, IsNil) defer store.Close() - saveConf := config.GetGlobalConfig() - conf := *saveConf - conf.Security.SkipGrantTable = true - config.StoreGlobalConfig(&conf) + defer config.RestoreFunc()() + config.UpdateGlobal(func(conf *config.Config) { + conf.Security.SkipGrantTable = true + }) dom, err := session.BootstrapSession(store) c.Assert(err, IsNil) @@ -560,8 +560,6 @@ func (s *testFlushSuite) TestFlushPrivilegesPanic(c *C) { tk := testkit.NewTestKit(c, store) tk.MustExec("FLUSH PRIVILEGES") - - config.StoreGlobalConfig(saveConf) } func (s *testSuite3) TestDropStats(c *C) { diff --git a/executor/sort_test.go b/executor/sort_test.go index 1915bfa6dcd9d..4e87d3863a0e6 100644 --- a/executor/sort_test.go +++ b/executor/sort_test.go @@ -31,11 +31,10 @@ func (s *testSerialSuite1) TestSortInDisk(c *C) { } func (s *testSerialSuite1) testSortInDisk(c *C, removeDir bool) { - originCfg := config.GetGlobalConfig() - newConf := *originCfg - newConf.OOMUseTmpStorage = true - config.StoreGlobalConfig(&newConf) - defer config.StoreGlobalConfig(originCfg) + defer config.RestoreFunc()() + config.UpdateGlobal(func(conf *config.Config) { + conf.OOMUseTmpStorage = true + }) c.Assert(failpoint.Enable("github.com/pingcap/tidb/executor/testSortedRowContainerSpill", "return(true)"), IsNil) defer func() { c.Assert(failpoint.Disable("github.com/pingcap/tidb/executor/testSortedRowContainerSpill"), IsNil) diff --git a/executor/statement_context_test.go b/executor/statement_context_test.go index 3bb049c96889c..a340a0cf96694 100644 --- a/executor/statement_context_test.go +++ b/executor/statement_context_test.go @@ -102,14 +102,13 @@ func (s *testSuite1) TestStatementContext(c *C) { _, err = tk.Exec("insert t1 values (unhex('F0A48BAE'))") c.Assert(err, NotNil) c.Assert(terror.ErrorEqual(err, table.ErrTruncatedWrongValueForField), IsTrue, Commentf("err %v", err)) - old := config.GetGlobalConfig() - conf := *old - conf.CheckMb4ValueInUTF8 = false - config.StoreGlobalConfig(&conf) + config.UpdateGlobal(func(conf *config.Config) { + conf.CheckMb4ValueInUTF8 = false + }) tk.MustExec("insert t1 values (unhex('f09f8c80'))") - conf2 := *old - conf2.CheckMb4ValueInUTF8 = true - config.StoreGlobalConfig(&conf2) + config.UpdateGlobal(func(conf *config.Config) { + conf.CheckMb4ValueInUTF8 = true + }) _, err = tk.Exec("insert t1 values (unhex('F0A48BAE'))") c.Assert(err, NotNil) } diff --git a/executor/write_concurrent_test.go b/executor/write_concurrent_test.go index dffb474dd714f..4eb5ded77539d 100644 --- a/executor/write_concurrent_test.go +++ b/executor/write_concurrent_test.go @@ -30,13 +30,10 @@ func (s *testSuite) TestBatchInsertWithOnDuplicate(c *C) { tk.MustExec(ctx, "create table duplicate_test(id int auto_increment, k1 int, primary key(id), unique key uk(k1))") tk.MustExec(ctx, "insert into duplicate_test(k1) values(?),(?),(?),(?),(?)", tk.PermInt(5)...) - cfg := config.GetGlobalConfig() - newCfg := *cfg - newCfg.EnableBatchDML = true - config.StoreGlobalConfig(&newCfg) - defer func() { - config.StoreGlobalConfig(cfg) - }() + defer config.RestoreFunc()() + config.UpdateGlobal(func(conf *config.Config) { + conf.EnableBatchDML = true + }) tk.ConcurrentRun(c, 3, 2, // concurrent: 3, loops: 2, // prepare data for each loop. diff --git a/go.mod b/go.mod index df46ec316bd4b..66a3dc8f80e8d 100644 --- a/go.mod +++ b/go.mod @@ -20,6 +20,8 @@ require ( github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4 github.com/iancoleman/strcase v0.0.0-20191112232945-16388991a334 github.com/klauspost/cpuid v1.2.1 + github.com/mattn/go-colorable v0.1.7 // indirect + github.com/mattn/go-runewidth v0.0.9 // indirect github.com/ngaut/pools v0.0.0-20180318154953-b7bc8c42aac7 github.com/ngaut/sync2 v0.0.0-20141008032647-7a24ed77b2ef github.com/opentracing/basictracer-go v1.0.0 @@ -27,13 +29,13 @@ require ( github.com/pingcap/br v0.0.0-20200805095214-09dcc7534821 github.com/pingcap/check v0.0.0-20200212061837-5e12011dc712 github.com/pingcap/errors v0.11.5-0.20190809092503-95897b64e011 - github.com/pingcap/failpoint v0.0.0-20200603062251-b230c36c413c + github.com/pingcap/failpoint v0.0.0-20200702092429-9f69995143ce github.com/pingcap/fn v0.0.0-20191016082858-07623b84a47d github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989 - github.com/pingcap/kvproto v0.0.0-20200706115936-1e0910aabe6c + github.com/pingcap/kvproto v0.0.0-20200818080353-7aaed8998596 github.com/pingcap/log v0.0.0-20200511115504-543df19646ad github.com/pingcap/parser v0.0.0-20200803072748-fdf66528323d - github.com/pingcap/pd/v4 v4.0.0-rc.2.0.20200520083007-2c251bd8f181 + github.com/pingcap/pd/v4 v4.0.5-0.20200817114353-e465cafe8a91 github.com/pingcap/sysutil v0.0.0-20200715082929-4c47bcac246a github.com/pingcap/tidb-tools v4.0.1-0.20200530144555-cdec43635625+incompatible github.com/pingcap/tipb v0.0.0-20200522051215-f31a15d98fce @@ -51,13 +53,16 @@ require ( go.uber.org/atomic v1.6.0 go.uber.org/automaxprocs v1.2.0 go.uber.org/zap v1.15.0 - golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e - golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e - golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd + golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc + golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208 + golang.org/x/sys v0.0.0-20200819171115-d785dc25833f golang.org/x/text v0.3.3 - golang.org/x/tools v0.0.0-20200521211927-2b542361a4fc + golang.org/x/tools v0.0.0-20200820010801-b793a1359eac + golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect google.golang.org/grpc v1.26.0 gopkg.in/natefinch/lumberjack.v2 v2.0.0 + gopkg.in/yaml.v2 v2.3.0 // indirect + honnef.co/go/tools v0.0.1-2020.1.5 // indirect sourcegraph.com/sourcegraph/appdash v0.0.0-20180531100431-4c381bd170b4 sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67 ) diff --git a/go.sum b/go.sum index bf3a48907e6d7..17eb8af5a5974 100644 --- a/go.sum +++ b/go.sum @@ -25,11 +25,14 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/Jeffail/gabs/v2 v2.5.1 h1:ANfZYjpMlfTTKebycu4X1AgkVWumFVDYQl7JwOr4mDk= github.com/Jeffail/gabs/v2 v2.5.1/go.mod h1:xCn81vdHKxFUuWWAaD5jCTQDNPBMh5pPs9IJ+NcziBI= +github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk= github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= @@ -87,8 +90,10 @@ github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfc github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f h1:lBNOc5arjvs8E5mO2tbpBpLoyyu8B6e44T7hJy6potg= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/corona10/goimagehash v1.0.2/go.mod h1:/l9umBhvcHQXVtQO1V6Gp1yD20STawkhRnnX0D1bvVI= +github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/cznic/golex v0.0.0-20181122101858-9c343928389c/go.mod h1:+bmmJDNmKlhWNG+gwWCkaBoTy39Fs+bzRxVBzoTQbIc= @@ -127,6 +132,7 @@ github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= +github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4= github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94= github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= @@ -135,6 +141,7 @@ github.com/fsouza/fake-gcs-server v1.15.0/go.mod h1:HNxAJ/+FY/XSsxuwz8iIYdp2GtMm github.com/fsouza/fake-gcs-server v1.17.0 h1:OeH75kBZcZa3ZE+zz/mFdJ2btt9FgqfjI7gIh9+5fvk= github.com/fsouza/fake-gcs-server v1.17.0/go.mod h1:D1rTE4YCyHFNa99oyJJ5HyclvN/0uQR+pM/VdlL83bw= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32 h1:Mn26/9ZMNWSw9C9ERFA1PUxfmGpolnw2v0bKOREu5ew= github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32/go.mod h1:GIjDIg/heH5DOkXY3YJ/wNhfHsQHoXGjl8G8amsYQ1I= github.com/gin-contrib/gzip v0.0.1/go.mod h1:fGBJBCdt6qCZuCAOwWuFhBB4OOq9EFqlo5dEaFhhu5w= github.com/gin-contrib/sse v0.0.0-20170109093832-22d885f9ecc7/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= @@ -156,20 +163,25 @@ github.com/go-ole/go-ole v1.2.4 h1:nNBDSCOigTSiarFpYE9J/KtEA1IOW4CNeqT9TQDqCxI= github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM= github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg= +github.com/go-openapi/jsonpointer v0.19.3 h1:gihV7YNZK1iK6Tgwwsxo2rJbD1GTbdm72325Bq8FI3w= github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= github.com/go-openapi/jsonreference v0.19.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc= +github.com/go-openapi/jsonreference v0.19.3 h1:5cxNfTy0UVC3X8JL5ymxzyoUZmo8iZb+jeTWn7tUa8o= github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8= github.com/go-openapi/spec v0.19.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= github.com/go-openapi/spec v0.19.4/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo= +github.com/go-openapi/spec v0.19.7 h1:0xWSeMd35y5avQAThZR2PkEuqSosoS5t6gDH4L8n11M= github.com/go-openapi/spec v0.19.7/go.mod h1:Hm2Jr4jv8G1ciIAo+frC/Ft+rR2kQDh8JHKHb3gWUSk= github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/swag v0.19.8 h1:vfK6jLhs7OI4tAXkvkooviaE1JEPcw3mutyegLHHjmk= github.com/go-openapi/swag v0.19.8/go.mod h1:ao+8BpOPyKdpQz3AOJfbeEVpLmWAvlT1IfTe5McPyhY= github.com/go-playground/locales v0.12.1/go.mod h1:IUMDtCfWo/w/mtMfIE/IG2K+Ey3ygWanZIBtBW0W2TM= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= +github.com/go-playground/overalls v0.0.0-20180201144345-22ec1a223b7c h1:3bjbKXoj7jBYdHpQFbKL2546c4dtltTHzjo+5i4CHBU= github.com/go-playground/overalls v0.0.0-20180201144345-22ec1a223b7c/go.mod h1:UqxAgEOt89sCiXlrc/ycnx00LVvUO/eS8tMUkWX4R7w= github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= @@ -308,11 +320,14 @@ github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czP github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.7.1 h1:mdxE1MF9o53iCb2Ghj1VfWvh7ZOwHpnVG/xwXrV90U8= github.com/mailru/easyjson v0.7.1/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-colorable v0.1.7 h1:bQGKb3vps/j0E9GfJQ03JyhRuxsvdAanXlT9BTw3mdw= +github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= @@ -320,16 +335,23 @@ github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2y github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= github.com/mattn/go-isatty v0.0.11 h1:FxPOTFNqGkuDUGi3H/qkUbQO4ZiBa2brKq5r0l8TGeM= github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= +github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.7 h1:Ei8KR0497xHyKJPAv59M1dkC+rOZCMBJ+t3fZ+twI54= github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= +github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= +github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-shellwords v1.0.3/go.mod h1:3xCvwCdWdlDJUrvuMn7Wuy9eWs4pE8vqg+NOMyg4B2o= github.com/mattn/go-sqlite3 v2.0.1+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/mgechev/dots v0.0.0-20190921121421-c36f7dcfbb81 h1:QASJXOGm2RZ5Ardbc86qNFvby9AqkLDibfChMtAg5QM= github.com/mgechev/dots v0.0.0-20190921121421-c36f7dcfbb81/go.mod h1:KQ7+USdGKfpPjXk4Ga+5XxQM4Lm4e3gAogrreFAYpOg= +github.com/mgechev/revive v1.0.2 h1:v0NxxQ7fSFz/u1NQydPo6EGdq7va0J1BtsZmae6kzUg= github.com/mgechev/revive v1.0.2/go.mod h1:rb0dQy1LVAxW9SWy5R3LPUjevzUbUS316U5MFySA2lo= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -352,6 +374,7 @@ github.com/ngaut/sync2 v0.0.0-20141008032647-7a24ed77b2ef/go.mod h1:7WjlapSfwQyo github.com/nicksnyder/go-i18n v1.10.0/go.mod h1:HrK7VCrbOvQoUAQ7Vpy7i87N7JZZZ7R2xBGjv0j365Q= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= +github.com/olekukonko/tablewriter v0.0.4 h1:vHD/YYe1Wolo78koG299f7V/VAS08c6IpCLn+Ejf/w8= github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA= github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -370,11 +393,13 @@ github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsq github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.3.0/go.mod h1:PN7xzY2wHTK0K9p34ErDQMlFxa51Fk0OUruD3k1mMwo= +github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 h1:q2e307iGHPdTGp0hoxKjt1H5pDo6utceo3dQVK3I5XQ= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= github.com/phf/go-queue v0.0.0-20170504031614-9abe38d0371d h1:U+PMnTlV2tu7RuMK5etusZG3Cf+rpow5hqQByeCzJ2g= github.com/phf/go-queue v0.0.0-20170504031614-9abe38d0371d/go.mod h1:lXfE4PvvTW5xOjO6Mba8zDPyw8M93B6AQ7frTGnMlA8= github.com/pingcap-incubator/tidb-dashboard v0.0.0-20200407064406-b2b8ad403d01/go.mod h1:77fCh8d3oKzC5ceOJWeZXAS/mLzVgdZ7rKniwmOyFuo= github.com/pingcap-incubator/tidb-dashboard v0.0.0-20200514075710-eecc9a4525b5/go.mod h1:8q+yDx0STBPri8xS4A2duS1dAf+xO0cMtjwe0t6MWJk= +github.com/pingcap-incubator/tidb-dashboard v0.0.0-20200807020752-01f0abe88e93/go.mod h1:9yaAM77sPfa5/f6sdxr3jSkKfIz463KRHyiFHiGjdes= github.com/pingcap/br v0.0.0-20200426093517-dd11ae28b885/go.mod h1:4w3meMnk7HDNpNgjuRAxavruTeKJvUiXxoEWTjzXPnA= github.com/pingcap/br v0.0.0-20200521085655-53201addd4ad/go.mod h1:SlSUHWY7QUoooiYxOKuJ8kUh2KjI29ogBh89YXz2dLA= github.com/pingcap/br v0.0.0-20200623060633-439a1c2b2bfd h1:vEoTsslkTbSiMMAY8XHsI/D0gih8y/kOPQytXYgc7t0= @@ -399,6 +424,8 @@ github.com/pingcap/failpoint v0.0.0-20200210140405-f8f9fb234798/go.mod h1:DNS3Qg github.com/pingcap/failpoint v0.0.0-20200506114213-c17f16071c53/go.mod h1:w4PEZ5y16LeofeeGwdgZB4ddv9bLyDuIX+ljstgKZyk= github.com/pingcap/failpoint v0.0.0-20200603062251-b230c36c413c h1:cm0zAj+Tab94mp4OH+VoLJiSNQvZO4pWDGJ8KEk2a0c= github.com/pingcap/failpoint v0.0.0-20200603062251-b230c36c413c/go.mod h1:w4PEZ5y16LeofeeGwdgZB4ddv9bLyDuIX+ljstgKZyk= +github.com/pingcap/failpoint v0.0.0-20200702092429-9f69995143ce h1:Y1kCxlCtlPTMtVcOkjUcuQKh+YrluSo7+7YMCQSzy30= +github.com/pingcap/failpoint v0.0.0-20200702092429-9f69995143ce/go.mod h1:w4PEZ5y16LeofeeGwdgZB4ddv9bLyDuIX+ljstgKZyk= github.com/pingcap/fn v0.0.0-20191016082858-07623b84a47d h1:rCmRK0lCRrHMUbS99BKFYhK9YxJDNw0xB033cQbYo0s= github.com/pingcap/fn v0.0.0-20191016082858-07623b84a47d/go.mod h1:fMRU1BA1y+r89AxUoaAar4JjrhUkVDt0o0Np6V8XbDQ= github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989 h1:surzm05a8C9dN8dIUmo4Be2+pMRb6f55i+UIYrluu2E= @@ -414,6 +441,8 @@ github.com/pingcap/kvproto v0.0.0-20200518112156-d4aeb467de29 h1:NpW1OuYrIl+IQrS github.com/pingcap/kvproto v0.0.0-20200518112156-d4aeb467de29/go.mod h1:IOdRDPLyda8GX2hE/jO7gqaCV/PNFh8BZQCQZXfIOqI= github.com/pingcap/kvproto v0.0.0-20200706115936-1e0910aabe6c h1:VnLpCAxMAeDxc7HXTetwDQB+/MtDQjHAOBsd4QnGVwA= github.com/pingcap/kvproto v0.0.0-20200706115936-1e0910aabe6c/go.mod h1:IOdRDPLyda8GX2hE/jO7gqaCV/PNFh8BZQCQZXfIOqI= +github.com/pingcap/kvproto v0.0.0-20200818080353-7aaed8998596 h1:1cRjX7+yHQiE4pV/xwB8XcbZXV9sHshWMNTd5I6SS2o= +github.com/pingcap/kvproto v0.0.0-20200818080353-7aaed8998596/go.mod h1:IOdRDPLyda8GX2hE/jO7gqaCV/PNFh8BZQCQZXfIOqI= github.com/pingcap/log v0.0.0-20191012051959-b742a5d432e9/go.mod h1:4rbK1p9ILyIfb6hU7OG2CiWSqMXnp3JMbiaVJ6mvoY8= github.com/pingcap/log v0.0.0-20200117041106-d28c14d3b1cd/go.mod h1:4rbK1p9ILyIfb6hU7OG2CiWSqMXnp3JMbiaVJ6mvoY8= github.com/pingcap/log v0.0.0-20200511115504-543df19646ad h1:SveG82rmu/GFxYanffxsSF503SiQV+2JLnWEiGiF+Tc= @@ -427,6 +456,8 @@ github.com/pingcap/parser v0.0.0-20200803072748-fdf66528323d/go.mod h1:vQdbJqobJ github.com/pingcap/pd/v4 v4.0.0-rc.1.0.20200422143320-428acd53eba2/go.mod h1:s+utZtXDznOiL24VK0qGmtoHjjXNsscJx3m1n8cC56s= github.com/pingcap/pd/v4 v4.0.0-rc.2.0.20200520083007-2c251bd8f181 h1:FM+PzdoR3fmWAJx3ug+p5aOgs5aZYwFkoDL7Potdsz0= github.com/pingcap/pd/v4 v4.0.0-rc.2.0.20200520083007-2c251bd8f181/go.mod h1:q4HTx/bA8aKBa4S7L+SQKHvjRPXCRV0tA0yRw0qkZSA= +github.com/pingcap/pd/v4 v4.0.5-0.20200817114353-e465cafe8a91 h1:zCOWP+kIzM6ZsXdu2QoM/W6+3vFZj04MYboMP2Obc0E= +github.com/pingcap/pd/v4 v4.0.5-0.20200817114353-e465cafe8a91/go.mod h1:m9OEkKoPMQWjrbJ9pqjjeCqzqxraZrPEuWa1OI6Wcek= github.com/pingcap/sysutil v0.0.0-20200206130906-2bfa6dc40bcd/go.mod h1:EB/852NMQ+aRKioCpToQ94Wl7fktV+FNnxf3CX/TTXI= github.com/pingcap/sysutil v0.0.0-20200408114249-ed3bd6f7fdb1/go.mod h1:EB/852NMQ+aRKioCpToQ94Wl7fktV+FNnxf3CX/TTXI= github.com/pingcap/sysutil v0.0.0-20200715082929-4c47bcac246a h1:i2RElJ2aykSqZKeY+3SK18NHhajil8cQdG77wHe+P1Y= @@ -481,8 +512,11 @@ github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6So github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= +github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= +github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/sasha-s/go-deadlock v0.2.0 h1:lMqc+fUb7RrFS3gQLtoQsJ7/6TV/pAIFvBsqX73DK8Y= github.com/sasha-s/go-deadlock v0.2.0/go.mod h1:StQn567HiB1fF2yJ44N9au7wOhrPS3iZqiDbRupzT10= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sergi/go-diff v1.0.1-0.20180205163309-da645544ed44 h1:tB9NOR21++IjLyVx3/PCPhWMwqGNCMQEH96A6dMZ/gc= @@ -493,9 +527,13 @@ github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4 h1:udFKJ0aHUL60LboW/A+D github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc= github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749 h1:bUGsEnyNbVPw06Bs80sCeARAlK8lhwqGyi6UT8ymuGk= github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg= +github.com/shurcooL/httpgzip v0.0.0-20190720172056-320755c1c1b0/go.mod h1:919LwcH0M7/W4fcZ0/jy0qGght1GIhqyS/EgWGH2j5Q= +github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/shurcooL/vfsgen v0.0.0-20181020040650-a97a25d856ca h1:3fECS8atRjByijiI8yYiuwLwQ2ZxXobW7ua/8GRB3pI= github.com/shurcooL/vfsgen v0.0.0-20181020040650-a97a25d856ca/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw= +github.com/shurcooL/vfsgen v0.0.0-20181202132449-6a9ea43bcacd h1:ug7PpSOB5RBPK1Kg6qskGBoP3Vnj/aNYFTznWvlkGo0= +github.com/shurcooL/vfsgen v0.0.0-20181202132449-6a9ea43bcacd/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I= @@ -533,6 +571,8 @@ github.com/swaggo/swag v1.5.1/go.mod h1:1Bl9F/ZBpVWh22nY0zmYyASPO1lI/zIwRDrpZU+t github.com/swaggo/swag v1.6.3/go.mod h1:wcc83tB4Mb2aNiL/HP4MFeQdpHUrca+Rp/DRNgWAUio= github.com/swaggo/swag v1.6.5/go.mod h1:Y7ZLSS0d0DdxhWGVhQdu+Bu1QhaF5k0RD7FKdiAykeY= github.com/swaggo/swag v1.6.6-0.20200323071853-8e21f4cefeea/go.mod h1:xDhTyuFIujYiN3DKWC/H/83xcfHp+UE/IzWWampG7Zc= +github.com/swaggo/swag v1.6.6-0.20200529100950-7c765ddd0476 h1:UjnSXdNPIG+5FJ6xLQODEdk7gSnJlMldu3sPAxxCO+4= +github.com/swaggo/swag v1.6.6-0.20200529100950-7c765ddd0476/go.mod h1:xDhTyuFIujYiN3DKWC/H/83xcfHp+UE/IzWWampG7Zc= github.com/syndtr/goleveldb v0.0.0-20180815032940-ae2bd5eed72d h1:4J9HCZVpvDmj2tiKGSTUnb3Ok/9CEQb9oqu9LHKQQpc= github.com/syndtr/goleveldb v0.0.0-20180815032940-ae2bd5eed72d/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0= github.com/syndtr/goleveldb v1.0.1-0.20190625010220-02440ea7a285 h1:uSDYjYejelKyceA6DiCsngFof9jAyeaSyX9XC5a1a7Q= @@ -563,15 +603,19 @@ github.com/ugorji/go/codec v1.1.5-pre/go.mod h1:tULtS6Gy1AE1yCENaw4Vb//HLH5njI2t github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= github.com/unrolled/render v0.0.0-20171102162132-65450fb6b2d3/go.mod h1:tu82oB5W2ykJRVioYsB+IQKcft7ryBr7w12qMBUPyXg= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= +github.com/urfave/cli v1.22.2 h1:gsqYFH8bb9ekPA12kRo0hfjngWQjkJPlN9R0N78BoUo= github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/urfave/cli/v2 v2.1.1 h1:Qt8FeAtxE/vfdrLmR3rxR6JRE0RoVmbXu8+6kZtYU4k= github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= github.com/urfave/negroni v0.3.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= +github.com/yookoala/realpath v1.0.0 h1:7OA9pj4FZd+oZDsyvXWQvjn5oBdcHRTV44PpdMSuImQ= github.com/yookoala/realpath v1.0.0/go.mod h1:gJJMA9wuX7AcqLy1+ffPatSCySA1FQ2S8Ya9AIoYBpE= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.3 h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= @@ -620,6 +664,8 @@ golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200204104054-c9f3fb736b72 h1:+ELyKg6m8UBf0nPFSqD0mi7zUfwPyXo23HNjMnXPz7w= golang.org/x/crypto v0.0.0-20200204104054-c9f3fb736b72/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -649,6 +695,8 @@ golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0 h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -675,6 +723,11 @@ golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e h1:3G+cUijn7XD+S4eJFddp53Pv7+slrESplyjG25HgL+k= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2 h1:eDrdRpKgkcCqKZQwyZRyeFZgfqt37SL7Kv3tok06cKE= +golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc h1:zK/HqS5bZxDptfPJNq8v7vJfXtkU7r9TLIoSr1bXaP4= +golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -687,6 +740,8 @@ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208 h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -713,9 +768,13 @@ golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200819171115-d785dc25833f h1:KJuwZVtZBVzDmEDtB2zro9CXkD9O0dpCv4o2LHbQIAw= +golang.org/x/sys v0.0.0-20200819171115-d785dc25833f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= @@ -765,10 +824,16 @@ golang.org/x/tools v0.0.0-20200325203130-f53864d0dba1 h1:odiryKYJy7CjdrZxhrcE1Z8 golang.org/x/tools v0.0.0-20200325203130-f53864d0dba1/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= golang.org/x/tools v0.0.0-20200521211927-2b542361a4fc h1:6m2YO+AmBApbUOmhsghW+IfRyZOY4My4UYvQQrEpHfY= golang.org/x/tools v0.0.0-20200521211927-2b542361a4fc/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200527183253-8e7acdbce89d h1:SR+e35rACZFBohNb4Om1ibX6N3iO0FtdbwqGSuD9dBU= +golang.org/x/tools v0.0.0-20200527183253-8e7acdbce89d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200820010801-b793a1359eac h1:DugppSxw0LSF8lcjaODPJZoDzq0ElTGskTst3ZaBkHI= +golang.org/x/tools v0.0.0-20200820010801-b793a1359eac/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= @@ -839,6 +904,8 @@ gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= @@ -848,6 +915,8 @@ honnef.co/go/tools v0.0.1-2020.1.3 h1:sXmLre5bzIR6ypkjXCDI3jHPssRhc8KD/Ome589sc3 honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4 h1:UoveltGrhghAA7ePc+e+QYDHXrBps2PqFZiHkGR/xK8= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.0.1-2020.1.5 h1:nI5egYTGJakVyOryqLs1cQO5dO0ksin5XXs2pspk75k= +honnef.co/go/tools v0.0.1-2020.1.5/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= diff --git a/infoschema/tables_test.go b/infoschema/tables_test.go index 6af6956b2d437..4e1f937ac849d 100644 --- a/infoschema/tables_test.go +++ b/infoschema/tables_test.go @@ -133,9 +133,9 @@ func (s *testClusterTableSuite) setUpRPCService(c *C, addr string) (*grpc.Server err = srv.Serve(lis) c.Assert(err, IsNil) }() - cfg := config.GetGlobalConfig() - cfg.Status.StatusPort = uint(port) - config.StoreGlobalConfig(cfg) + config.UpdateGlobal(func(conf *config.Config) { + conf.Status.StatusPort = uint(port) + }) return srv, addr } diff --git a/planner/core/cbo_test.go b/planner/core/cbo_test.go index beb92834823aa..7efc5a32c9ea7 100644 --- a/planner/core/cbo_test.go +++ b/planner/core/cbo_test.go @@ -431,13 +431,13 @@ func (s *testAnalyzeSuite) TestPreparedNullParam(c *C) { store.Close() }() - cfg := config.GetGlobalConfig() - orgEnable := cfg.PreparedPlanCache.Enabled - orgCapacity := cfg.PreparedPlanCache.Capacity + defer config.RestoreFunc()() flags := []bool{false, true} for _, flag := range flags { - cfg.PreparedPlanCache.Enabled = flag - cfg.PreparedPlanCache.Capacity = 100 + config.UpdateGlobal(func(conf *config.Config) { + conf.PreparedPlanCache.Enabled = flag + conf.PreparedPlanCache.Capacity = 100 + }) testKit := testkit.NewTestKit(c, store) testKit.MustExec("use test") testKit.MustExec("drop table if exists t") @@ -460,8 +460,6 @@ func (s *testAnalyzeSuite) TestPreparedNullParam(c *C) { c.Assert(core.ToString(p), Equals, best, Commentf("for %s", sql)) } - cfg.PreparedPlanCache.Enabled = orgEnable - cfg.PreparedPlanCache.Capacity = orgCapacity } func (s *testAnalyzeSuite) TestNullCount(c *C) { diff --git a/planner/core/integration_test.go b/planner/core/integration_test.go index 4b56269924be3..dbc83562db188 100644 --- a/planner/core/integration_test.go +++ b/planner/core/integration_test.go @@ -303,8 +303,10 @@ func (s *testIntegrationSerialSuite) TestNoneAccessPathsFoundByIsolationRead(c * tk.MustExec("set @@session.tidb_isolation_read_engines = 'tiflash, tikv'") tk.MustExec("select * from t") - config.GetGlobalConfig().IsolationRead.Engines = []string{"tiflash"} - defer func() { config.GetGlobalConfig().IsolationRead.Engines = []string{"tikv", "tiflash"} }() + defer config.RestoreFunc()() + config.UpdateGlobal(func(conf *config.Config) { + conf.IsolationRead.Engines = []string{"tiflash"} + }) // Change instance config doesn't affect isolation read. tk.MustExec("select * from t") } diff --git a/session/session_test.go b/session/session_test.go index 7b84427a56e77..b0c56b62ef9e7 100644 --- a/session/session_test.go +++ b/session/session_test.go @@ -171,7 +171,9 @@ func (s *testSessionSuiteBase) SetUpSuite(c *C) { initPdAddrs() s.pdAddr = <-pdAddrChan var d tikv.Driver - config.GetGlobalConfig().TxnLocalLatches.Enabled = false + config.UpdateGlobal(func(conf *config.Config) { + conf.TxnLocalLatches.Enabled = false + }) store, err := d.Open(fmt.Sprintf("tikv://%s", s.pdAddr)) c.Assert(err, IsNil) err = clearStorage(store) @@ -2462,11 +2464,10 @@ func (s *testSessionSuite2) TestStatementErrorInTransaction(c *C) { func (s *testSessionSerialSuite) TestStatementCountLimit(c *C) { tk := testkit.NewTestKitWithInit(c, s.store) tk.MustExec("create table stmt_count_limit (id int)") - saved := config.GetGlobalConfig().Performance.StmtCountLimit - config.GetGlobalConfig().Performance.StmtCountLimit = 3 - defer func() { - config.GetGlobalConfig().Performance.StmtCountLimit = saved - }() + defer config.RestoreFunc()() + config.UpdateGlobal(func(conf *config.Config) { + conf.Performance.StmtCountLimit = 3 + }) tk.MustExec("set tidb_disable_txn_auto_retry = 0") tk.MustExec("begin") tk.MustExec("insert into stmt_count_limit values (1)") @@ -2488,11 +2489,10 @@ func (s *testSessionSerialSuite) TestBatchCommit(c *C) { tk.MustExec("set tidb_batch_commit = 1") tk.MustExec("set tidb_disable_txn_auto_retry = 0") tk.MustExec("create table t (id int)") - saved := config.GetGlobalConfig().Performance - config.GetGlobalConfig().Performance.StmtCountLimit = 3 - defer func() { - config.GetGlobalConfig().Performance = saved - }() + defer config.RestoreFunc()() + config.UpdateGlobal(func(conf *config.Config) { + conf.Performance.StmtCountLimit = 3 + }) tk1 := testkit.NewTestKitWithInit(c, s.store) tk.MustExec("SET SESSION autocommit = 1") tk.MustExec("begin") @@ -2756,11 +2756,10 @@ func (s *testSchemaSuite) TestDisableTxnAutoRetry(c *C) { // test for disable transaction local latch tk1.Se.GetSessionVars().InRestrictedSQL = false - orgCfg := config.GetGlobalConfig() - disableLatchCfg := *orgCfg - disableLatchCfg.TxnLocalLatches.Enabled = false - config.StoreGlobalConfig(&disableLatchCfg) - defer config.StoreGlobalConfig(orgCfg) + defer config.RestoreFunc()() + config.UpdateGlobal(func(conf *config.Config) { + conf.TxnLocalLatches.Enabled = false + }) tk1.MustExec("begin") tk1.MustExec("update no_retry set id = 9") @@ -2772,9 +2771,9 @@ func (s *testSchemaSuite) TestDisableTxnAutoRetry(c *C) { c.Assert(strings.Contains(err.Error(), kv.TxnRetryableMark), IsTrue, Commentf("error: %s", err)) tk1.MustExec("rollback") - enableLatchCfg := *orgCfg - enableLatchCfg.TxnLocalLatches.Enabled = true - config.StoreGlobalConfig(&enableLatchCfg) + config.UpdateGlobal(func(conf *config.Config) { + conf.TxnLocalLatches.Enabled = true + }) tk1.MustExec("begin") tk2.MustExec("alter table no_retry add index idx(id)") tk2.MustQuery("select * from no_retry").Check(testkit.Rows("8")) diff --git a/sessionctx/variable/session_test.go b/sessionctx/variable/session_test.go index b21ca69270f4e..abbdc7b11ff1a 100644 --- a/sessionctx/variable/session_test.go +++ b/sessionctx/variable/session_test.go @@ -223,11 +223,10 @@ select * from t;` } func (*testSessionSuite) TestIsolationRead(c *C) { - originIsolationEngines := config.GetGlobalConfig().IsolationRead.Engines - defer func() { - config.GetGlobalConfig().IsolationRead.Engines = originIsolationEngines - }() - config.GetGlobalConfig().IsolationRead.Engines = []string{"tiflash", "tidb"} + defer config.RestoreFunc()() + config.UpdateGlobal(func(conf *config.Config) { + conf.IsolationRead.Engines = []string{"tiflash", "tidb"} + }) sessVars := variable.NewSessionVars() _, ok := sessVars.IsolationReadEngines[kv.TiDB] c.Assert(ok, Equals, true) diff --git a/store/mockstore/mocktikv/pd.go b/store/mockstore/mocktikv/pd.go index c5ca89132354f..6f76bf02a7c91 100644 --- a/store/mockstore/mocktikv/pd.go +++ b/store/mockstore/mocktikv/pd.go @@ -22,7 +22,7 @@ import ( "github.com/pingcap/errors" "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" - "github.com/pingcap/pd/v4/client" + pd "github.com/pingcap/pd/v4/client" ) // Use global variables to prevent pdClients from creating duplicate timestamps. @@ -51,10 +51,6 @@ func NewPDClient(cluster *Cluster) pd.Client { } } -func (c *pdClient) ConfigClient() pd.ConfigClient { - return nil -} - func (c *pdClient) GetClusterID(ctx context.Context) uint64 { return 1 } diff --git a/store/mockstore/tikv_test.go b/store/mockstore/tikv_test.go index c638e6648b382..afa85a876099d 100644 --- a/store/mockstore/tikv_test.go +++ b/store/mockstore/tikv_test.go @@ -31,10 +31,12 @@ func (s testSuite) SetUpSuite(c *C) {} var _ = Suite(testSuite{}) func (s testSuite) TestConfig(c *C) { - config.GetGlobalConfig().TxnLocalLatches = config.TxnLocalLatches{ - Enabled: true, - Capacity: 10240, - } + config.UpdateGlobal(func(conf *config.Config) { + conf.TxnLocalLatches = config.TxnLocalLatches{ + Enabled: true, + Capacity: 10240, + } + }) type LatchEnableChecker interface { IsLatchEnabled() bool @@ -46,10 +48,12 @@ func (s testSuite) TestConfig(c *C) { c.Assert(store.(LatchEnableChecker).IsLatchEnabled(), IsTrue) store.Close() - config.GetGlobalConfig().TxnLocalLatches = config.TxnLocalLatches{ - Enabled: false, - Capacity: 10240, - } + config.UpdateGlobal(func(conf *config.Config) { + conf.TxnLocalLatches = config.TxnLocalLatches{ + Enabled: false, + Capacity: 10240, + } + }) store, err = driver.Open("mocktikv://") c.Assert(err, IsNil) c.Assert(store.(LatchEnableChecker).IsLatchEnabled(), IsFalse) diff --git a/store/tikv/region_request_test.go b/store/tikv/region_request_test.go index 20401748629aa..e75b4e5c7fbab 100644 --- a/store/tikv/region_request_test.go +++ b/store/tikv/region_request_test.go @@ -422,30 +422,6 @@ func (s *mockTikvGrpcServer) ReadIndex(context.Context, *kvrpcpb.ReadIndexReques return nil, errors.New("unreachable") } -func (s *mockTikvGrpcServer) VerGet(context.Context, *kvrpcpb.VerGetRequest) (*kvrpcpb.VerGetResponse, error) { - return nil, errors.New("unreachable") -} - -func (s *mockTikvGrpcServer) VerBatchGet(context.Context, *kvrpcpb.VerBatchGetRequest) (*kvrpcpb.VerBatchGetResponse, error) { - return nil, errors.New("unreachable") -} - -func (s *mockTikvGrpcServer) VerMut(context.Context, *kvrpcpb.VerMutRequest) (*kvrpcpb.VerMutResponse, error) { - return nil, errors.New("unreachable") -} - -func (s *mockTikvGrpcServer) VerBatchMut(context.Context, *kvrpcpb.VerBatchMutRequest) (*kvrpcpb.VerBatchMutResponse, error) { - return nil, errors.New("unreachable") -} - -func (s *mockTikvGrpcServer) VerScan(context.Context, *kvrpcpb.VerScanRequest) (*kvrpcpb.VerScanResponse, error) { - return nil, errors.New("unreachable") -} - -func (s *mockTikvGrpcServer) VerDeleteRange(context.Context, *kvrpcpb.VerDeleteRangeRequest) (*kvrpcpb.VerDeleteRangeResponse, error) { - return nil, errors.New("unreachable") -} - func (s *testRegionRequestSuite) TestNoReloadRegionForGrpcWhenCtxCanceled(c *C) { // prepare a mock tikv grpc server addr := "localhost:56341" diff --git a/store/tikv/store_test.go b/store/tikv/store_test.go index 06cc47bb1a0e2..0b6a2404ac485 100644 --- a/store/tikv/store_test.go +++ b/store/tikv/store_test.go @@ -24,7 +24,7 @@ import ( pb "github.com/pingcap/kvproto/pkg/kvrpcpb" "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" - "github.com/pingcap/pd/v4/client" + pd "github.com/pingcap/pd/v4/client" "github.com/pingcap/tidb/kv" "github.com/pingcap/tidb/store/mockoracle" "github.com/pingcap/tidb/store/tikv/tikvrpc" @@ -105,10 +105,6 @@ type mockPDClient struct { stop bool } -func (c *mockPDClient) ConfigClient() pd.ConfigClient { - return nil -} - func (c *mockPDClient) enable() { c.Lock() defer c.Unlock() diff --git a/tidb-server/main_test.go b/tidb-server/main_test.go index f745c7533904e..6cca1689c438d 100644 --- a/tidb-server/main_test.go +++ b/tidb-server/main_test.go @@ -42,9 +42,10 @@ type testMainSuite struct{} func (t *testMainSuite) TestSetGlobalVars(c *C) { c.Assert(variable.SysVars[variable.TiDBIsolationReadEngines].Value, Equals, "tikv, tiflash, tidb") c.Assert(variable.SysVars[variable.TIDBMemQuotaQuery].Value, Equals, "1073741824") - - config.GetGlobalConfig().IsolationRead.Engines = []string{"tikv", "tidb"} - config.GetGlobalConfig().MemQuotaQuery = 9999999 + config.UpdateGlobal(func(conf *config.Config) { + conf.IsolationRead.Engines = []string{"tikv", "tidb"} + conf.MemQuotaQuery = 9999999 + }) setGlobalVars() c.Assert(variable.SysVars[variable.TiDBIsolationReadEngines].Value, Equals, "tikv, tidb") diff --git a/util/chunk/chunk_test.go b/util/chunk/chunk_test.go index 2048f95bdee64..68ef2bad196f9 100644 --- a/util/chunk/chunk_test.go +++ b/util/chunk/chunk_test.go @@ -36,12 +36,12 @@ import ( ) func TestT(t *testing.T) { - cfg := config.GetGlobalConfig() - conf := *cfg - conf.TempStoragePath, _ = ioutil.TempDir("", "oom-use-tmp-storage") - config.StoreGlobalConfig(&conf) - _ = os.RemoveAll(conf.TempStoragePath) // clean the uncleared temp file during the last run. - _ = os.MkdirAll(conf.TempStoragePath, 0755) + path, _ := ioutil.TempDir("", "oom-use-tmp-storage") + config.UpdateGlobal(func(conf *config.Config) { + conf.TempStoragePath = path + }) + _ = os.RemoveAll(path) // clean the uncleared temp file during the last run. + _ = os.MkdirAll(path, 0755) check.TestingT(t) }