diff --git a/br/cmd/br/backup.go b/br/cmd/br/backup.go index 925cf58c132b4..d8b313ce504f3 100644 --- a/br/cmd/br/backup.go +++ b/br/cmd/br/backup.go @@ -46,8 +46,13 @@ func runBackupCommand(command *cobra.Command, cmdName string) error { return nil } - // No need to cache the coproceesor result - config.GetGlobalConfig().TiKVClient.CoprCache.CapacityMB = 0 + config.UpdateGlobal(func(conf *config.Config) { + // Need to be skipped when the cluster has TiDB type coprocessor tasks + conf.AdvertiseAddress = config.UnavailableIP + + // No need to cache the coproceesor result + conf.TiKVClient.CoprCache.CapacityMB = 0 + }) // Disable the memory limit tuner. That's because the server memory is get from TiDB node instead of BR node. gctuner.GlobalMemoryLimitTuner.DisableAdjustMemoryLimit() diff --git a/br/cmd/br/restore.go b/br/cmd/br/restore.go index f991163813af2..cbf9ccff5f329 100644 --- a/br/cmd/br/restore.go +++ b/br/cmd/br/restore.go @@ -65,8 +65,13 @@ func runRestoreCommand(command *cobra.Command, cmdName string) error { return nil } - // No need to cache the coproceesor result - config.GetGlobalConfig().TiKVClient.CoprCache.CapacityMB = 0 + config.UpdateGlobal(func(conf *config.Config) { + // Need to be skipped when the cluster has TiDB type coprocessor tasks + conf.AdvertiseAddress = config.UnavailableIP + + // No need to cache the coproceesor result + conf.TiKVClient.CoprCache.CapacityMB = 0 + }) // Disable the memory limit tuner. That's because the server memory is get from TiDB node instead of BR node. gctuner.GlobalMemoryLimitTuner.DisableAdjustMemoryLimit() diff --git a/pkg/config/config.go b/pkg/config/config.go index 56f6fd66a2a5f..262fd24d43b56 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -100,6 +100,7 @@ const ( // MaxTokenLimit is the max token limit value. MaxTokenLimit = 1024 * 1024 DefSchemaLease = 45 * time.Second + UnavailableIP = "" ) // Valid config maps diff --git a/pkg/executor/infoschema_cluster_table_test.go b/pkg/executor/infoschema_cluster_table_test.go index 9e25309369d67..568a381762197 100644 --- a/pkg/executor/infoschema_cluster_table_test.go +++ b/pkg/executor/infoschema_cluster_table_test.go @@ -208,6 +208,19 @@ func (s *mockStore) StartGCWorker() error { panic("not implemented") } func (s *mockStore) Name() string { return "mockStore" } func (s *mockStore) Describe() string { return "" } +func TestSkipEmptyIPNodesForTiDBTypeCoprocessor(t *testing.T) { + originIP := config.GetGlobalConfig().AdvertiseAddress + config.GetGlobalConfig().AdvertiseAddress = config.UnavailableIP + defer func() { config.GetGlobalConfig().AdvertiseAddress = originIP }() + store, _ := testkit.CreateMockStoreAndDomain(t) + tk := testkit.NewTestKit(t, store) + tk.MustExec("use test") + rows := tk.MustQuery("select * from information_schema.cluster_slow_query").Rows() + require.Equal(t, tk.Session().GetSessionVars().StmtCtx.WarningCount(), uint16(0)) + // the TiDB node is skipped because it does not has IP + require.Equal(t, 0, len(rows)) +} + func TestTiDBClusterInfo(t *testing.T) { s := createInfosSchemaClusterTableSuite(t) diff --git a/pkg/store/copr/coprocessor.go b/pkg/store/copr/coprocessor.go index 085dfbe350779..ca9866073a371 100644 --- a/pkg/store/copr/coprocessor.go +++ b/pkg/store/copr/coprocessor.go @@ -595,6 +595,10 @@ func buildTiDBMemCopTasks(ranges *KeyRanges, req *kv.Request) ([]*copTask, error if req.TiDBServerID > 0 && req.TiDBServerID != ser.ServerIDGetter() { continue } + // skip some nodes, such as BR created when backup/restore + if ser.IP == config.UnavailableIP { + continue + } addr := net.JoinHostPort(ser.IP, strconv.FormatUint(uint64(ser.StatusPort), 10)) tasks = append(tasks, &copTask{