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

schedulers: enable transfer-witness-leader by default #5883

Merged
merged 1 commit into from
Jan 30, 2023
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
25 changes: 14 additions & 11 deletions server/cluster/coordinator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,7 @@ func TestAddScheduler(t *testing.T) {
re.NoError(co.removeScheduler(schedulers.HotRegionName))
re.NoError(co.removeScheduler(schedulers.SplitBucketName))
re.NoError(co.removeScheduler(schedulers.BalanceWitnessName))
re.NoError(co.removeScheduler(schedulers.TransferWitnessLeaderName))
re.Empty(co.schedulers)

stream := mockhbstream.NewHeartbeatStream()
Expand Down Expand Up @@ -789,7 +790,7 @@ func TestPersistScheduler(t *testing.T) {
re.NoError(tc.addLeaderStore(1, 1))
re.NoError(tc.addLeaderStore(2, 1))

re.Len(co.schedulers, 5)
re.Len(co.schedulers, 6)
oc := co.opController
storage := tc.RaftCluster.storage

Expand All @@ -799,15 +800,16 @@ func TestPersistScheduler(t *testing.T) {
evict, err := schedule.CreateScheduler(schedulers.EvictLeaderType, oc, storage, schedule.ConfigSliceDecoder(schedulers.EvictLeaderType, []string{"2"}))
re.NoError(err)
re.NoError(co.addScheduler(evict, "2"))
re.Len(co.schedulers, 7)
re.Len(co.schedulers, 8)
sches, _, err := storage.LoadAllScheduleConfig()
re.NoError(err)
re.Len(sches, 7)
re.Len(sches, 8)
re.NoError(co.removeScheduler(schedulers.BalanceLeaderName))
re.NoError(co.removeScheduler(schedulers.BalanceRegionName))
re.NoError(co.removeScheduler(schedulers.HotRegionName))
re.NoError(co.removeScheduler(schedulers.SplitBucketName))
re.NoError(co.removeScheduler(schedulers.BalanceWitnessName))
re.NoError(co.removeScheduler(schedulers.TransferWitnessLeaderName))
re.Len(co.schedulers, 2)
re.NoError(co.cluster.opt.Persist(storage))
co.stop()
Expand All @@ -823,15 +825,15 @@ func TestPersistScheduler(t *testing.T) {
defer func() {
config.DefaultSchedulers = config.DefaultSchedulers[:len(config.DefaultSchedulers)-1]
}()
re.Len(newOpt.GetSchedulers(), 5)
re.Len(newOpt.GetSchedulers(), 6)
re.NoError(newOpt.Reload(storage))
// only remains 3 items with independent config.
sches, _, err = storage.LoadAllScheduleConfig()
re.NoError(err)
re.Len(sches, 3)

// option have 6 items because the default scheduler do not remove.
re.Len(newOpt.GetSchedulers(), 8)
re.Len(newOpt.GetSchedulers(), 9)
re.NoError(newOpt.Persist(storage))
tc.RaftCluster.opt = newOpt

Expand All @@ -858,10 +860,10 @@ func TestPersistScheduler(t *testing.T) {

// the scheduler option should contain 6 items
// the `hot scheduler` are disabled
re.Len(co.cluster.opt.GetSchedulers(), 8)
re.Len(co.cluster.opt.GetSchedulers(), 9)
re.NoError(co.removeScheduler(schedulers.GrantLeaderName))
// the scheduler that is not enable by default will be completely deleted
re.Len(co.cluster.opt.GetSchedulers(), 7)
re.Len(co.cluster.opt.GetSchedulers(), 8)
re.Len(co.schedulers, 4)
re.NoError(co.cluster.opt.Persist(co.cluster.storage))
co.stop()
Expand Down Expand Up @@ -893,17 +895,17 @@ func TestRemoveScheduler(t *testing.T) {
re.NoError(tc.addLeaderStore(1, 1))
re.NoError(tc.addLeaderStore(2, 1))

re.Len(co.schedulers, 5)
re.Len(co.schedulers, 6)
oc := co.opController
storage := tc.RaftCluster.storage

gls1, err := schedule.CreateScheduler(schedulers.GrantLeaderType, oc, storage, schedule.ConfigSliceDecoder(schedulers.GrantLeaderType, []string{"1"}))
re.NoError(err)
re.NoError(co.addScheduler(gls1, "1"))
re.Len(co.schedulers, 6)
re.Len(co.schedulers, 7)
sches, _, err := storage.LoadAllScheduleConfig()
re.NoError(err)
re.Len(sches, 6)
re.Len(sches, 7)

// remove all schedulers
re.NoError(co.removeScheduler(schedulers.BalanceLeaderName))
Expand All @@ -912,6 +914,7 @@ func TestRemoveScheduler(t *testing.T) {
re.NoError(co.removeScheduler(schedulers.GrantLeaderName))
re.NoError(co.removeScheduler(schedulers.SplitBucketName))
re.NoError(co.removeScheduler(schedulers.BalanceWitnessName))
re.NoError(co.removeScheduler(schedulers.TransferWitnessLeaderName))
// all removed
sches, _, err = storage.LoadAllScheduleConfig()
re.NoError(err)
Expand All @@ -930,7 +933,7 @@ func TestRemoveScheduler(t *testing.T) {
co.run()
re.Empty(co.schedulers)
// the option remains default scheduler
re.Len(co.cluster.opt.GetSchedulers(), 5)
re.Len(co.cluster.opt.GetSchedulers(), 6)
co.stop()
co.wg.Wait()
}
Expand Down
1 change: 1 addition & 0 deletions server/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,7 @@ var DefaultSchedulers = SchedulerConfigs{
{Type: "balance-witness"},
{Type: "hot-region"},
{Type: "split-bucket"},
{Type: "transfer-witness-leader"},
}

// IsDefaultScheduler checks whether the scheduler is enable by default.
Expand Down