Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coprocessor: skip empty tidb nodes #56858

Merged
merged 8 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions br/cmd/br/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
9 changes: 7 additions & 2 deletions br/cmd/br/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ const (
// MaxTokenLimit is the max token limit value.
MaxTokenLimit = 1024 * 1024
DefSchemaLease = 45 * time.Second
UnavailableIP = "<nil>"
Leavrth marked this conversation as resolved.
Show resolved Hide resolved
)

// Valid config maps
Expand Down
13 changes: 13 additions & 0 deletions pkg/executor/infoschema_cluster_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 4 additions & 0 deletions pkg/store/copr/coprocessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,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{
Expand Down