diff --git a/cmd/cmd.go b/cmd/cmd.go index fdba0cbdd..a1fc3cf4d 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -25,7 +25,7 @@ var ( initOnce = sync.Once{} defaultContext context.Context hasLogFile uint64 - tidbGlue = gluetidb.Glue{} + tidbGlue = gluetidb.New() envLogToTermKey = "BR_LOG_TO_TERM" ) diff --git a/pkg/gluetidb/glue.go b/pkg/gluetidb/glue.go index 7633b8064..3e2a76756 100644 --- a/pkg/gluetidb/glue.go +++ b/pkg/gluetidb/glue.go @@ -5,9 +5,11 @@ package gluetidb import ( "context" + "github.com/pingcap/log" "github.com/pingcap/parser/model" "github.com/pingcap/parser/mysql" pd "github.com/pingcap/pd/v4/client" + "github.com/pingcap/tidb/config" "github.com/pingcap/tidb/ddl" "github.com/pingcap/tidb/domain" "github.com/pingcap/tidb/kv" @@ -17,6 +19,15 @@ import ( "github.com/pingcap/br/pkg/gluetikv" ) +// New makes a new tidb glue. +func New() Glue { + log.Debug("enabling no register config") + config.UpdateGlobal(func(conf *config.Config) { + conf.SkipRegisterToDashboard = true + }) + return Glue{} +} + // Glue is an implementation of glue.Glue using a new TiDB session. type Glue struct { tikvGlue gluetikv.Glue diff --git a/pkg/restore/client_test.go b/pkg/restore/client_test.go index 96425ffb4..d61a74b46 100644 --- a/pkg/restore/client_test.go +++ b/pkg/restore/client_test.go @@ -40,7 +40,7 @@ func (s *testRestoreClientSuite) TestCreateTables(c *C) { c.Assert(s.mock.Start(), IsNil) defer s.mock.Stop() - client, err := restore.NewRestoreClient(context.Background(), gluetidb.Glue{}, s.mock.PDClient, s.mock.Storage, nil) + client, err := restore.NewRestoreClient(context.Background(), gluetidb.New(), s.mock.PDClient, s.mock.Storage, nil) c.Assert(err, IsNil) info, err := s.mock.Domain.GetSnapshotInfoSchema(math.MaxInt64) @@ -98,7 +98,7 @@ func (s *testRestoreClientSuite) TestIsOnline(c *C) { c.Assert(s.mock.Start(), IsNil) defer s.mock.Stop() - client, err := restore.NewRestoreClient(context.Background(), gluetidb.Glue{}, s.mock.PDClient, s.mock.Storage, nil) + client, err := restore.NewRestoreClient(context.Background(), gluetidb.New(), s.mock.PDClient, s.mock.Storage, nil) c.Assert(err, IsNil) c.Assert(client.IsOnline(), IsFalse) diff --git a/pkg/restore/db_test.go b/pkg/restore/db_test.go index d37b48182..435c29c53 100644 --- a/pkg/restore/db_test.go +++ b/pkg/restore/db_test.go @@ -74,7 +74,7 @@ func (s *testRestoreSchemaSuite) TestRestoreAutoIncID(c *C) { c.Assert(autoIncID, Equals, uint64(globalAutoID)) // Alter AutoIncID to the next AutoIncID + 100 table.Info.AutoIncID = globalAutoID + 100 - db, err := restore.NewDB(gluetidb.Glue{}, s.mock.Storage) + db, err := restore.NewDB(gluetidb.New(), s.mock.Storage) c.Assert(err, IsNil, Commentf("Error create DB")) tk.MustExec("drop database if exists test;") // Test empty collate value