-
Notifications
You must be signed in to change notification settings - Fork 6.2k
resource group: starter mode support degrade to default RU group #68105
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
Open
ystaticy
wants to merge
23
commits into
pingcap:master
Choose a base branch
from
ystaticy:use_default_ru
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
929c7ce
support default RU group
ystaticy 40d3dea
only in starter
ystaticy df69722
fix name
ystaticy 6d1c37c
Merge remote-tracking branch 'origin/master' into use_default_ru
ystaticy 6d1ebff
domain: use deploy mode for Starter RU fallback
ystaticy 25cacf4
fix error
ystaticy 29ff847
fix comments
ystaticy 8054a7f
fix comments
ystaticy 0c6d89d
fix build
ystaticy 73f9e5a
fix ut
ystaticy 636fcd9
fix build
ystaticy 73062cc
resolve conflict
ystaticy a633842
fix ut
ystaticy cf2bf7f
fix code format
ystaticy 7a97d4e
use with degradedResourceGroup
ystaticy d1989e5
fix config
ystaticy 0ea629f
fix comments
ystaticy 59c011f
update pd client
ystaticy 5e8359b
add config
ystaticy 87fec4d
fix discussion_r3586340548
ystaticy 16506f7
add code comments
ystaticy 606f1bf
remove unused code
ystaticy 8b9cf6d
fix config name
ystaticy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| // Copyright 2026 PingCAP, Inc. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package domain | ||
|
|
||
| import ( | ||
| "time" | ||
|
|
||
| rmpb "github.com/pingcap/kvproto/pkg/resource_manager" | ||
| "github.com/pingcap/tidb/pkg/config" | ||
| "github.com/pingcap/tidb/pkg/config/deploymode" | ||
| "github.com/pingcap/tidb/pkg/resourcegroup/runaway" | ||
| rmclient "github.com/tikv/pd/client/resource_group/controller" | ||
| ) | ||
|
|
||
| const ( | ||
| defaultDegradedRUFillRate = 2_000_000 | ||
| defaultDegradedRUBurstLimit = 50_000_000_000 | ||
| defaultDegradedModeWaitTimeout = 3 * time.Second / 2 | ||
| tokenWaitRetryInterval = 100 * time.Millisecond | ||
| tokenWaitRetryTimes = 20 | ||
| ) | ||
|
|
||
| func newDefaultDegradedRUSettings() *rmpb.GroupRequestUnitSettings { | ||
| return &rmpb.GroupRequestUnitSettings{ | ||
| RU: &rmpb.TokenBucket{ | ||
| Settings: &rmpb.TokenLimitSettings{ | ||
| FillRate: defaultDegradedRUFillRate, | ||
| BurstLimit: defaultDegradedRUBurstLimit, | ||
| }, | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| func newResourceGroupsControllerOptions() []rmclient.ResourceControlCreateOption { | ||
| opts := []rmclient.ResourceControlCreateOption{ | ||
| rmclient.WithMaxWaitDuration(runaway.MaxWaitDuration), | ||
| } | ||
| if deploymode.IsStarter() && config.GetGlobalConfig().StarterParams.EnableRGFallback { | ||
| opts = append(opts, | ||
| // This Starter-only fallback path is a best-effort UX fallback for | ||
| // temporary GetResourceGroup failures. It provides a permissive | ||
| // group so user requests do not fail immediately; it is not intended | ||
| // to define a precise cross-RPC RU limit or response-side accounting | ||
| // contract while resource manager is unavailable. Keep synthesis | ||
| // inside the controller so degraded groups are not inserted into the | ||
| // normal metadata cache. | ||
| rmclient.WithDegradedRUSettings(newDefaultDegradedRUSettings()), | ||
| rmclient.WithDegradedModeWaitDuration(defaultDegradedModeWaitTimeout), | ||
| rmclient.WithWaitRetryInterval(tokenWaitRetryInterval), | ||
| rmclient.WithWaitRetryTimes(tokenWaitRetryTimes), | ||
| ) | ||
| } | ||
| return opts | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.