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

resource_manager/client: Don't set token as -1 in burstable mode #6216

Merged
merged 9 commits into from
Mar 24, 2023

Conversation

CabinfeverB
Copy link
Member

@CabinfeverB CabinfeverB commented Mar 23, 2023

What problem does this PR solve?

Issue Number: Close #6209

What is changed and how does it work?

Before this PR, the token of limiter is set to -1 in burst mode. But ref #6209, after stopping workload, the avg will be zore. So the required token will be zero. If we disable burstable, the token and fillratre are both zero, so workload can not run.
This PR block token refill when in burstable mode and keep the token as FillRate.

Check List

Tests

  • Integration test
  • Manual test (add detailed scripts or steps below)
  1. mysql> alter resource group rg1 RU_PER_SEC=10000 BURSTABLE;
    image
  2. run sysbench and kill it.
    image
  3. wait 1 minute and alter resource group rg1 RU_PER_SEC=1000;
    image
  4. run sysbench again.
    Uploading image.png…

Release note

None.

Signed-off-by: Cabinfever_B <[email protected]>
Signed-off-by: Cabinfever_B <[email protected]>
Signed-off-by: Cabinfever_B <[email protected]>
Signed-off-by: Cabinfever_B <[email protected]>
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Mar 23, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • JmPotato
  • nolouch

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added release-note-none Denotes a PR that doesn't merit a release note. needs-cherry-pick-release-7.0 labels Mar 23, 2023
@ti-chi-bot ti-chi-bot requested review from JmPotato and nolouch March 23, 2023 08:20
@codecov
Copy link

codecov bot commented Mar 23, 2023

Codecov Report

Patch coverage: 73.68% and project coverage change: +0.06 🎉

Comparison is base (19f7dd9) 74.71% compared to head (279124d) 74.77%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6216      +/-   ##
==========================================
+ Coverage   74.71%   74.77%   +0.06%     
==========================================
  Files         395      395              
  Lines       38826    38846      +20     
==========================================
+ Hits        29008    29048      +40     
+ Misses       7274     7261      -13     
+ Partials     2544     2537       -7     
Flag Coverage Δ
unittests 74.77% <73.68%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
client/resource_group/controller/controller.go 73.59% <72.72%> (+0.85%) ⬆️
client/resource_group/controller/limiter.go 72.35% <75.00%> (-0.04%) ⬇️

... and 28 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

fillRate := getRUTokenBucketSetting(gc.ResourceGroup, typ)
cfg.NewBurst = int64(fillRate.Settings.FillRate)
cfg.NewRate = float64(fillRate.Settings.FillRate)
tb := counter.getTokenBucketFunc()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe can directly get fillrate?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

fillRate := getRawResourceTokenBucketSetting(gc.ResourceGroup, typ)
cfg.NewBurst = int64(fillRate.Settings.FillRate)
cfg.NewRate = float64(fillRate.Settings.FillRate)
tb := counter.getTokenBucketFunc()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 23, 2023
lim.limit = Limit(args.NewRate)
lim.burst = args.NewBurst
_, _, lim.tokens = lim.advance(now)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not advance before lim.last = now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to avoid accumulating too many tokens when burst is -1. Because the first advance was before the burst changes, we want to advance after the burst changes.
But I feel this worry is unnecessary, I will delete this line

Signed-off-by: Cabinfever_B <[email protected]>
Signed-off-by: Cabinfever_B <[email protected]>
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 23, 2023
Copy link
Contributor

@nolouch nolouch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Mar 23, 2023
@@ -334,6 +334,114 @@ func (suite *resourceManagerClientTestSuite) TestResourceGroupController() {
controller.Stop()
}

// TestSwitchBurst is used to test https://github.com/tikv/pd/issue/6209
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#6209
issues miss a s :)

Signed-off-by: Cabinfever_B <[email protected]>
Copy link
Member

@HuSharp HuSharp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

REST LGTM!

// In the non-trickle case, clients can be allowed to accumulate more tokens.
if cfg.NewBurst >= 0 {
cfg.NewBurst = 0
cfg.NotifyThreshold = math.Min((granted+counter.limiter.AvailableTokens(gc.run.now)), counter.avgRUPerSec*defaultTargetPeriod.Seconds()) * notifyFraction
Copy link
Member

@HuSharp HuSharp Mar 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundant bracket

lim.tokens = tokens + args.NewTokens
log.Debug("[resource group controller] before reconfigure", zap.Float64("NewTokens", lim.tokens), zap.Float64("NewRate", float64(lim.limit)), zap.Float64("NotifyThreshold", args.NotifyThreshold), zap.Int64("burst", lim.burst))
if args.NewBurst < 0 {
lim.tokens = args.NewTokens
Copy link
Member

@HuSharp HuSharp Mar 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The annotation for the limiter field last is last is the last time the token field of the limiter was updated
So for this change do we need to update annotation or will this cause some unexpect behavior?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it and will update last here as well

@ti-chi-bot
Copy link
Member

@HuSharp: Thanks for your review. The bot only counts approvals from reviewers and higher roles in list, but you're still welcome to leave your comments.

In response to this:

REST LGTM!

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

Signed-off-by: Cabinfever_B <[email protected]>
@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Mar 24, 2023
@JmPotato
Copy link
Member

/merge

@ti-chi-bot
Copy link
Member

@JmPotato: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 279124d

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Mar 24, 2023
@ti-chi-bot ti-chi-bot merged commit 79ec29c into tikv:master Mar 24, 2023
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.0: #6220.

ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this pull request Mar 24, 2023
CabinfeverB added a commit to ti-chi-bot/pd that referenced this pull request Mar 24, 2023
ti-chi-bot added a commit that referenced this pull request Mar 24, 2023
…6216) (#6220)

close #6209, ref #6209, ref #6216

Signed-off-by: Cabinfever_B <[email protected]>

Co-authored-by: Yongbo Jiang <[email protected]>
@JmPotato JmPotato deleted the resource-manager/fix_burst branch March 24, 2023 05:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cherry-pick-release-7.0 release-note-none Denotes a PR that doesn't merit a release note. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exceeded resource group quota limitation when switching burstable twice
5 participants