Skip to content

Commit

Permalink
br: use merge-schedule-limit to pause merge
Browse files Browse the repository at this point in the history
  • Loading branch information
3pointer committed Sep 26, 2023
1 parent 62a048c commit 9e27ea9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
6 changes: 2 additions & 4 deletions br/pkg/pdutil/pd.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ var (
"shuffle-hot-region-scheduler": {},
}
expectPDCfgGenerators = map[string]pauseConfigGenerator{
"max-merge-region-keys": zeroPauseConfig,
"max-merge-region-size": zeroPauseConfig,
"merge-schedule-limit": zeroPauseConfig,
// TODO "leader-schedule-limit" and "region-schedule-limit" don't support ttl for now,
// but we still need set these config for compatible with old version.
// we need wait for https://github.com/tikv/pd/pull/3131 merged.
Expand All @@ -134,8 +133,7 @@ var (
// defaultPDCfg find by https://github.com/tikv/pd/blob/master/conf/config.toml.
// only use for debug command.
defaultPDCfg = map[string]interface{}{
"max-merge-region-keys": 200000,
"max-merge-region-size": 20,
"merge-schedule-limit": 8,
"leader-schedule-limit": 4,
"region-schedule-limit": 2048,
"enable-location-replacement": "true",
Expand Down
20 changes: 7 additions & 13 deletions br/tests/br_other/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,14 @@ run_curl https://$PD_ADDR/pd/api/v1/config/schedule | grep '"disable": false'
# after apply the pause api. these configs won't change any more.
# run_curl https://$PD_ADDR/pd/api/v1/config/schedule | jq '."enable-location-replacement"' | grep "false"
# run_curl https://$PD_ADDR/pd/api/v1/config/schedule | jq '."max-pending-peer-count"' | grep "2147483647"
# run_curl https://$PD_ADDR/pd/api/v1/config/schedule | jq '."max-merge-region-size"' | grep -E "^0$"
# run_curl https://$PD_ADDR/pd/api/v1/config/schedule | jq '."max-merge-region-keys"' | grep -E "^0$"
# run_curl https://$PD_ADDR/pd/api/v1/config/schedule | jq '."merge-schedule-limit"' | grep -E "^0$"

# after https://github.com/tikv/pd/pull/4781 merged.
# we can use a hack way to check whether we pause config succeed.
# By setting a paused config again and expect to fail with a clear message.
run_pd_ctl -u https://$PD_ADDR config set max-merge-region-size 0 | grep -q "need to clean up TTL first for schedule.max-merge-region-size"
run_pd_ctl -u https://$PD_ADDR config set max-merge-region-keys 0 | grep -q "need to clean up TTL first for schedule.max-merge-region-keys"
run_pd_ctl -u https://$PD_ADDR config set max-pending-peer-count 0 | grep -q "need to clean up TTL first for schedule.max-pending-peer-count"
run_pd_ctl -u https://$PD_ADDR config set enable-location-replacement false | grep -q "need to clean up TTL first for schedule.enable-location-replacement"
run_pd_ctl -u https://$PD_ADDR config set merge-schedule-limit 0 | grep -q "need to clean up TTL first for schedule.merge-schedule-limit"
run_pd_ctl -u https://$PD_ADDR config set leader-schedule-limit 0 | grep -q "need to clean up TTL first for schedule.leader-schedule-limit"
run_pd_ctl -u https://$PD_ADDR config set region-schedule-limit 0 | grep -q "need to clean up TTL first for schedule.region-schedule-limit"
run_pd_ctl -u https://$PD_ADDR config set max-snapshot-count 0 | grep -q "need to clean up TTL first for schedule.max-snapshot-count"
Expand Down Expand Up @@ -147,8 +145,7 @@ fi


default_pd_values='{
"max-merge-region-keys": 200000,
"max-merge-region-size": 20,
"merge-schedule-limit": 8,
"leader-schedule-limit": 4,
"region-schedule-limit": 2048
}'
Expand All @@ -170,7 +167,7 @@ pause_schedulers=$(curl https://$PD_ADDR/pd/api/v1/schedulers?status="paused" |
exit 1
fi

pd_settings=6
pd_settings=5

# balance-region scheduler enabled
run_curl https://$PD_ADDR/pd/api/v1/config/schedule | jq '."schedulers-v2"[] | {disable: .disable, type: ."type" | select (.=="balance-region")}' | grep '"disable": false' || ((pd_settings--))
Expand All @@ -185,13 +182,10 @@ run_curl https://$PD_ADDR/pd/api/v1/config/schedule | jq '."enable-location-repl
# until pd has the solution to temporary set these scheduler/configs.
run_br validate reset-pd-config-as-default --pd $PD_ADDR

# max-merge-region-size set to default 20
run_curl https://$PD_ADDR/pd/api/v1/config/schedule | jq '."max-merge-region-size"' | grep "20" || ((pd_settings--))
# merge-schedule-limit set to default 8
run_curl https://$PD_ADDR/pd/api/v1/config/schedule | jq '."merge-schedule-limit"' | grep "8" || ((pd_settings--))

# max-merge-region-keys set to default 200000
run_curl https://$PD_ADDR/pd/api/v1/config/schedule | jq '."max-merge-region-keys"' | grep "200000" || ((pd_settings--))

if [ "$pd_settings" -ne "6" ];then
if [ "$pd_settings" -ne "5" ];then
echo "TEST: [$TEST_NAME] test validate reset pd config failed!"
exit 1
fi
Expand Down

0 comments on commit 9e27ea9

Please sign in to comment.