-
Notifications
You must be signed in to change notification settings - Fork 720
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
scheduler: add conflict detect for grant hot leader scheduler #4903
Changes from 2 commits
071b116
4052699
ec5ecf9
201adb5
d3a9bf7
1f7991c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -354,9 +354,10 @@ func NewSplitBucketSchedulerCommand() *cobra.Command { | |
// NewGrantHotRegionSchedulerCommand returns a command to add a grant-hot-region-scheduler. | ||
func NewGrantHotRegionSchedulerCommand() *cobra.Command { | ||
c := &cobra.Command{ | ||
Use: "grant-hot-region-scheduler <store_leader_id> <store_leader_id,store_peer_id_1,store_peer_id_2>", | ||
Short: "add a scheduler to grant hot region to fixed stores", | ||
Run: addSchedulerForGrantHotRegionCommandFunc, | ||
Use: "grant-hot-region-scheduler <store_leader_id> <store_leader_id,store_peer_id_1,store_peer_id_2>", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BTW, is it necessary to set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, I also think it is not necessary. I will modify it in another pr. |
||
Short: `add a scheduler to grant hot region to fixed stores. | ||
Note: If there is balance-hot-region-scheduler running, please remove it first, otherwise grant-hot-region-scheduler will not work.`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it ok if the hot scheduler is not work but exist, for example being pause status? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this pr, even though the hot-scheduler is paused, adding grant-hot-leader-scheduler is still not allowed. If this is allowed, let's look at an example where I suspend the hot-scheduler for ten seconds and then add grant-hot-leader-scheduler, which is fine for ten seconds, but after ten seconds the hot-scheduler resumes scheduling and they will conflict again. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, understand. BTW, the hot scheduler config still exist if I enable it again. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the configuration still exists. If you think this pr is ok, I will cancel /hold. |
||
Run: addSchedulerForGrantHotRegionCommandFunc, | ||
} | ||
return c | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -488,12 +488,32 @@ func (suite *schedulerTestSuite) checkSchedulerConfig(cluster *pdTests.TestClust | |
}) | ||
|
||
// test grant hot region scheduler config | ||
checkSchedulerCommand(re, cmd, pdAddr, []string{"-u", pdAddr, "scheduler", "add", "grant-hot-region-scheduler", "1", "1,2,3"}, map[string]bool{ | ||
// case 1: add grant-hot-region-scheduler when balance-hot-region-scheduler is running | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should not belong to the scheduler config test. |
||
echo = mustExec(re, cmd, []string{"-u", pdAddr, "scheduler", "add", "grant-hot-region-scheduler", "1", "1,2,3"}, nil) | ||
re.Contains(echo, "balance-hot-region-scheduler is running, please remove it first") | ||
|
||
// case 2: add grant-hot-region-scheduler when balance-hot-region-scheduler is paused | ||
checkSchedulerCommand(re, cmd, pdAddr, []string{"-u", pdAddr, "scheduler", "pause", "balance-hot-region-scheduler", "60"}, map[string]bool{ | ||
"balance-region-scheduler": true, | ||
"balance-leader-scheduler": true, | ||
"balance-hot-region-scheduler": true, | ||
"grant-hot-region-scheduler": true, | ||
}) | ||
echo = mustExec(re, cmd, []string{"-u", pdAddr, "scheduler", "add", "grant-hot-region-scheduler", "1", "1,2,3"}, nil) | ||
re.Contains(echo, "balance-hot-region-scheduler is running, please remove it first") | ||
|
||
// case 3: add grant-hot-region-scheduler when balance-hot-region-scheduler is disabled | ||
checkSchedulerCommand(re, cmd, pdAddr, []string{"-u", pdAddr, "scheduler", "remove", "balance-hot-region-scheduler"}, map[string]bool{ | ||
"balance-region-scheduler": true, | ||
"balance-leader-scheduler": true, | ||
}) | ||
|
||
checkSchedulerCommand(re, cmd, pdAddr, []string{"-u", pdAddr, "scheduler", "add", "grant-hot-region-scheduler", "1", "1,2,3"}, map[string]bool{ | ||
"balance-region-scheduler": true, | ||
"balance-leader-scheduler": true, | ||
"grant-hot-region-scheduler": true, | ||
}) | ||
|
||
// case 4: test grant-hot-region-scheduler config | ||
var conf3 map[string]any | ||
expected3 := map[string]any{ | ||
"store-id": []any{float64(1), float64(2), float64(3)}, | ||
|
@@ -509,7 +529,17 @@ func (suite *schedulerTestSuite) checkSchedulerConfig(cluster *pdTests.TestClust | |
mustExec(re, cmd, []string{"-u", pdAddr, "scheduler", "config", "grant-hot-region-scheduler"}, &conf3) | ||
return reflect.DeepEqual(expected3, conf3) | ||
}) | ||
|
||
// case 5: remove grant-hot-region-scheduler | ||
echo = mustExec(re, cmd, []string{"-u", pdAddr, "scheduler", "add", "balance-hot-region-scheduler"}, nil) | ||
re.Contains(echo, "grant-hot-region-scheduler is running, please remove it first") | ||
|
||
checkSchedulerCommand(re, cmd, pdAddr, []string{"-u", pdAddr, "scheduler", "remove", "grant-hot-region-scheduler"}, map[string]bool{ | ||
"balance-region-scheduler": true, | ||
"balance-leader-scheduler": true, | ||
}) | ||
|
||
checkSchedulerCommand(re, cmd, pdAddr, []string{"-u", pdAddr, "scheduler", "add", "balance-hot-region-scheduler"}, map[string]bool{ | ||
"balance-region-scheduler": true, | ||
"balance-leader-scheduler": true, | ||
"balance-hot-region-scheduler": true, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to query schedulers from the scheduling service?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we need to check whether hot scheduler is disabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PD has the same configuration as the scheduling service?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done