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

config: disable witness related schedulers by default (#7765) #8892

Merged
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
2 changes: 0 additions & 2 deletions pkg/schedule/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,9 +525,7 @@ type SchedulerConfig struct {
var DefaultSchedulers = SchedulerConfigs{
{Type: "balance-region"},
{Type: "balance-leader"},
{Type: "balance-witness"},
{Type: "hot-region"},
{Type: "transfer-witness-leader"},
}

// IsDefaultScheduler checks whether the scheduler is enable by default.
Expand Down
17 changes: 6 additions & 11 deletions server/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3041,8 +3041,6 @@ func TestAddScheduler(t *testing.T) {
re.NoError(controller.RemoveScheduler(schedulers.BalanceLeaderName))
re.NoError(controller.RemoveScheduler(schedulers.BalanceRegionName))
re.NoError(controller.RemoveScheduler(schedulers.HotRegionName))
re.NoError(controller.RemoveScheduler(schedulers.BalanceWitnessName))
re.NoError(controller.RemoveScheduler(schedulers.TransferWitnessLeaderName))
re.Empty(controller.GetSchedulerNames())

stream := mockhbstream.NewHeartbeatStream()
Expand Down Expand Up @@ -3133,13 +3131,12 @@ func TestPersistScheduler(t *testing.T) {
re.NoError(err)
re.Len(sches, defaultCount+2)

// remove 5 schedulers
// remove 3 schedulers
re.NoError(controller.RemoveScheduler(schedulers.BalanceLeaderName))
re.NoError(controller.RemoveScheduler(schedulers.BalanceRegionName))
re.NoError(controller.RemoveScheduler(schedulers.HotRegionName))
re.NoError(controller.RemoveScheduler(schedulers.BalanceWitnessName))
re.NoError(controller.RemoveScheduler(schedulers.TransferWitnessLeaderName))
re.Len(controller.GetSchedulerNames(), defaultCount-3)
// only remains 2 items with independent config.
re.Len(controller.GetSchedulerNames(), 2)
re.NoError(co.GetCluster().GetSchedulerConfig().Persist(storage))
co.Stop()
co.GetSchedulersController().Wait()
Expand Down Expand Up @@ -3190,7 +3187,7 @@ func TestPersistScheduler(t *testing.T) {
brs, err := schedulers.CreateScheduler(schedulers.BalanceRegionType, oc, storage, schedulers.ConfigSliceDecoder(schedulers.BalanceRegionType, []string{"", ""}))
re.NoError(err)
re.NoError(controller.AddScheduler(brs))
re.Len(controller.GetSchedulerNames(), defaultCount)
re.Len(controller.GetSchedulerNames(), 5)

// the scheduler option should contain 6 items
// the `hot scheduler` are disabled
Expand All @@ -3211,9 +3208,9 @@ func TestPersistScheduler(t *testing.T) {

co.Run()
controller = co.GetSchedulersController()
re.Len(controller.GetSchedulerNames(), defaultCount-1)
re.Len(controller.GetSchedulerNames(), 4)
re.NoError(controller.RemoveScheduler(schedulers.EvictLeaderName))
re.Len(controller.GetSchedulerNames(), defaultCount-2)
re.Len(controller.GetSchedulerNames(), 3)
}

func TestRemoveScheduler(t *testing.T) {
Expand Down Expand Up @@ -3249,8 +3246,6 @@ func TestRemoveScheduler(t *testing.T) {
re.NoError(controller.RemoveScheduler(schedulers.BalanceRegionName))
re.NoError(controller.RemoveScheduler(schedulers.HotRegionName))
re.NoError(controller.RemoveScheduler(schedulers.GrantLeaderName))
re.NoError(controller.RemoveScheduler(schedulers.BalanceWitnessName))
re.NoError(controller.RemoveScheduler(schedulers.TransferWitnessLeaderName))
// all removed
sches, _, err = storage.LoadAllSchedulerConfigs()
re.NoError(err)
Expand Down
4 changes: 2 additions & 2 deletions tests/integrations/mcs/scheduling/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (suite *serverTestSuite) TestPrimaryChange() {
tc.WaitForPrimaryServing(re)
primary := tc.GetPrimaryServer()
oldPrimaryAddr := primary.GetAddr()
re.Len(primary.GetCluster().GetCoordinator().GetSchedulersController().GetSchedulerNames(), 5)
re.Len(primary.GetCluster().GetCoordinator().GetSchedulersController().GetSchedulerNames(), 3)
testutil.Eventually(re, func() bool {
watchedAddr, ok := suite.pdLeader.GetServicePrimaryAddr(suite.ctx, mcs.SchedulingServiceName)
return ok && oldPrimaryAddr == watchedAddr
Expand All @@ -137,7 +137,7 @@ func (suite *serverTestSuite) TestPrimaryChange() {
primary = tc.GetPrimaryServer()
newPrimaryAddr := primary.GetAddr()
re.NotEqual(oldPrimaryAddr, newPrimaryAddr)
re.Len(primary.GetCluster().GetCoordinator().GetSchedulersController().GetSchedulerNames(), 5)
re.Len(primary.GetCluster().GetCoordinator().GetSchedulersController().GetSchedulerNames(), 3)
testutil.Eventually(re, func() bool {
watchedAddr, ok := suite.pdLeader.GetServicePrimaryAddr(suite.ctx, mcs.SchedulingServiceName)
return ok && newPrimaryAddr == watchedAddr
Expand Down
84 changes: 31 additions & 53 deletions tests/pdctl/scheduler/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,18 @@ func (suite *schedulerTestSuite) checkScheduler(cluster *tests.TestCluster) {

// scheduler show command
expected := map[string]bool{
"balance-region-scheduler": true,
"balance-leader-scheduler": true,
"balance-hot-region-scheduler": true,
"transfer-witness-leader-scheduler": true,
"balance-witness-scheduler": true,
"balance-region-scheduler": true,
"balance-leader-scheduler": true,
"balance-hot-region-scheduler": true,
}
checkSchedulerCommand(nil, expected)

// scheduler delete command
args := []string{"-u", pdAddr, "scheduler", "remove", "balance-region-scheduler"}
time.Sleep(10 * time.Second)
expected = map[string]bool{
"balance-leader-scheduler": true,
"balance-hot-region-scheduler": true,
"transfer-witness-leader-scheduler": true,
"balance-witness-scheduler": true,
"balance-leader-scheduler": true,
"balance-hot-region-scheduler": true,
}
checkSchedulerCommand(args, expected)

Expand All @@ -136,11 +132,9 @@ func (suite *schedulerTestSuite) checkScheduler(cluster *tests.TestCluster) {
// scheduler add command
args = []string{"-u", pdAddr, "scheduler", "add", schedulers[idx], "2"}
expected = map[string]bool{
"balance-leader-scheduler": true,
"balance-hot-region-scheduler": true,
schedulers[idx]: true,
"transfer-witness-leader-scheduler": true,
"balance-witness-scheduler": true,
"balance-leader-scheduler": true,
"balance-hot-region-scheduler": true,
schedulers[idx]: true,
}
checkSchedulerCommand(args, expected)

Expand All @@ -152,11 +146,9 @@ func (suite *schedulerTestSuite) checkScheduler(cluster *tests.TestCluster) {
// scheduler config update command
args = []string{"-u", pdAddr, "scheduler", "config", schedulers[idx], "add-store", "3"}
expected = map[string]bool{
"balance-leader-scheduler": true,
"balance-hot-region-scheduler": true,
schedulers[idx]: true,
"transfer-witness-leader-scheduler": true,
"balance-witness-scheduler": true,
"balance-leader-scheduler": true,
"balance-hot-region-scheduler": true,
schedulers[idx]: true,
}
checkSchedulerCommand(args, expected)

Expand All @@ -167,32 +159,26 @@ func (suite *schedulerTestSuite) checkScheduler(cluster *tests.TestCluster) {
// scheduler delete command
args = []string{"-u", pdAddr, "scheduler", "remove", schedulers[idx]}
expected = map[string]bool{
"balance-leader-scheduler": true,
"balance-hot-region-scheduler": true,
"transfer-witness-leader-scheduler": true,
"balance-witness-scheduler": true,
"balance-leader-scheduler": true,
"balance-hot-region-scheduler": true,
}
checkSchedulerCommand(args, expected)

// scheduler add command
args = []string{"-u", pdAddr, "scheduler", "add", schedulers[idx], "2"}
expected = map[string]bool{
"balance-leader-scheduler": true,
"balance-hot-region-scheduler": true,
schedulers[idx]: true,
"transfer-witness-leader-scheduler": true,
"balance-witness-scheduler": true,
"balance-leader-scheduler": true,
"balance-hot-region-scheduler": true,
schedulers[idx]: true,
}
checkSchedulerCommand(args, expected)

// scheduler add command twice
args = []string{"-u", pdAddr, "scheduler", "add", schedulers[idx], "4"}
expected = map[string]bool{
"balance-leader-scheduler": true,
"balance-hot-region-scheduler": true,
schedulers[idx]: true,
"transfer-witness-leader-scheduler": true,
"balance-witness-scheduler": true,
"balance-leader-scheduler": true,
"balance-hot-region-scheduler": true,
schedulers[idx]: true,
}
checkSchedulerCommand(args, expected)

Expand All @@ -203,11 +189,9 @@ func (suite *schedulerTestSuite) checkScheduler(cluster *tests.TestCluster) {
// scheduler remove command [old]
args = []string{"-u", pdAddr, "scheduler", "remove", schedulers[idx] + "-4"}
expected = map[string]bool{
"balance-leader-scheduler": true,
"balance-hot-region-scheduler": true,
schedulers[idx]: true,
"transfer-witness-leader-scheduler": true,
"balance-witness-scheduler": true,
"balance-leader-scheduler": true,
"balance-hot-region-scheduler": true,
schedulers[idx]: true,
}
checkSchedulerCommand(args, expected)

Expand All @@ -218,21 +202,17 @@ func (suite *schedulerTestSuite) checkScheduler(cluster *tests.TestCluster) {
// scheduler remove command, when remove the last store, it should remove whole scheduler
args = []string{"-u", pdAddr, "scheduler", "remove", schedulers[idx] + "-2"}
expected = map[string]bool{
"balance-leader-scheduler": true,
"balance-hot-region-scheduler": true,
"transfer-witness-leader-scheduler": true,
"balance-witness-scheduler": true,
"balance-leader-scheduler": true,
"balance-hot-region-scheduler": true,
}
checkSchedulerCommand(args, expected)
}

// test shuffle region config
checkSchedulerCommand([]string{"-u", pdAddr, "scheduler", "add", "shuffle-region-scheduler"}, map[string]bool{
"balance-leader-scheduler": true,
"balance-hot-region-scheduler": true,
"shuffle-region-scheduler": true,
"transfer-witness-leader-scheduler": true,
"balance-witness-scheduler": true,
"balance-leader-scheduler": true,
"balance-hot-region-scheduler": true,
"shuffle-region-scheduler": true,
})
var roles []string
mustExec(re, cmd, []string{"-u", pdAddr, "scheduler", "config", "shuffle-region-scheduler", "show-roles"}, &roles)
Expand All @@ -245,12 +225,10 @@ func (suite *schedulerTestSuite) checkScheduler(cluster *tests.TestCluster) {

// test grant hot region scheduler config
checkSchedulerCommand([]string{"-u", pdAddr, "scheduler", "add", "grant-hot-region-scheduler", "1", "1,2,3"}, map[string]bool{
"balance-leader-scheduler": true,
"balance-hot-region-scheduler": true,
"shuffle-region-scheduler": true,
"grant-hot-region-scheduler": true,
"transfer-witness-leader-scheduler": true,
"balance-witness-scheduler": true,
"balance-leader-scheduler": true,
"balance-hot-region-scheduler": true,
"shuffle-region-scheduler": true,
"grant-hot-region-scheduler": true,
})
var conf3 map[string]interface{}
expected3 := map[string]interface{}{
Expand Down
6 changes: 3 additions & 3 deletions tests/server/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,7 @@ func TestTransferLeaderForScheduler(t *testing.T) {
})
// Check scheduler updated.
schedulersController := rc.GetCoordinator().GetSchedulersController()
re.Len(schedulersController.GetSchedulerNames(), 6)
re.Len(schedulersController.GetSchedulerNames(), 4)
checkEvictLeaderSchedulerExist(re, schedulersController, true)
checkEvictLeaderStoreIDs(re, schedulersController, []uint64{1, 2})

Expand All @@ -1436,7 +1436,7 @@ func TestTransferLeaderForScheduler(t *testing.T) {
re.True(leaderServer.GetRaftCluster().IsPrepared())
// Check scheduler updated.
schedulersController = rc1.GetCoordinator().GetSchedulersController()
re.Len(schedulersController.GetSchedulerNames(), 6)
re.Len(schedulersController.GetSchedulerNames(), 4)
checkEvictLeaderSchedulerExist(re, schedulersController, true)
checkEvictLeaderStoreIDs(re, schedulersController, []uint64{1, 2})

Expand All @@ -1455,7 +1455,7 @@ func TestTransferLeaderForScheduler(t *testing.T) {
re.True(leaderServer.GetRaftCluster().IsPrepared())
// Check scheduler updated
schedulersController = rc.GetCoordinator().GetSchedulersController()
re.Len(schedulersController.GetSchedulerNames(), 6)
re.Len(schedulersController.GetSchedulerNames(), 4)
checkEvictLeaderSchedulerExist(re, schedulersController, true)
checkEvictLeaderStoreIDs(re, schedulersController, []uint64{1, 2})

Expand Down
Loading