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

ddl, I_S: support runaway attribute in resource group #43877

Merged
merged 36 commits into from
Jun 6, 2023

Conversation

CabinfeverB
Copy link
Contributor

What problem does this PR solve?

Issue Number: ref #43691
should be merged after #43843

Problem Summary:

What is changed and how it works?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality 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]>
Signed-off-by: Cabinfever_B <[email protected]>
Signed-off-by: Cabinfever_B <[email protected]>
@ti-chi-bot
Copy link

ti-chi-bot bot commented May 16, 2023

[REVIEW NOTIFICATION]

This pull request has not been approved.

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
Copy link

ti-chi-bot bot commented May 16, 2023

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels May 16, 2023
@CabinfeverB CabinfeverB marked this pull request as ready for review May 23, 2023 07:43
@ti-chi-bot ti-chi-bot bot removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels May 23, 2023
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]>
Signed-off-by: Cabinfever_B <[email protected]>
@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 25, 2023
@ti-chi-bot ti-chi-bot bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 30, 2023
Signed-off-by: Cabinfever_B <[email protected]>

address comment

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

address comment

Signed-off-by: Cabinfever_B <[email protected]>
@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 30, 2023
@ti-chi-bot ti-chi-bot bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels May 31, 2023
Signed-off-by: Cabinfever_B <[email protected]>
@CabinfeverB
Copy link
Contributor Author

/test build

@@ -119,16 +125,20 @@ func TestResourceGroupBasic(t *testing.T) {
}
g = testResourceGroupNameFromIS(t, tk.Session(), "y")
checkFunc(g)
tk.MustExec("alter resource group y BURSTABLE RU_PER_SEC=5000")
tk.MustExec("alter resource group y BURSTABLE RU_PER_SEC=5000 QUERY_LIMIT=(EXEC_ELAPSED_IN_SEC='15s' ACTION KILL)")
Copy link
Member

Choose a reason for hiding this comment

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

It occurs to me that as we can pass any duration to EXEC_ELAPSED_IN_SEC, does IN_SEC make any sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. EXEC_ELAPSED is better. @songrijie

@CabinfeverB
Copy link
Contributor Author

cc @nolouch @glorv

ddl/resourcegrouptest/resource_group_test.go Outdated Show resolved Hide resolved
queryLimit := ""
if setting := group.RunawaySettings; setting != nil {
runawayRule, runawayAction, runawayWatch := "", "", ""
if setting.Rule != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems if rule == nil, the output will format it with a " ," which seems weird to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rule should never be nil. Currently, we only have ExecElapsed in Rule, and I check it in NewGroupFromOptions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Then I suggest remove this check or change it to check setting.Rule == nil and return error directly in this case.

Copy link
Member

@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 bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jun 5, 2023
Signed-off-by: Cabinfever_B <[email protected]>
@ti-chi-bot ti-chi-bot bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 6, 2023
Copy link
Contributor

@glorv glorv left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +3277 to +3293
// convert runaway settings
queryLimit := ""
if setting := group.RunawaySettings; setting != nil {
runawayRule, runawayAction, runawayWatch := "", "", ""
if setting.Rule == nil {
return errors.Errorf("unexpected runaway config in resource group")
}
dur := time.Duration(setting.Rule.ExecElapsedTimeMs) * time.Millisecond
runawayRule = fmt.Sprintf("%s=%s", "EXEC_ELAPSED", dur.String())
runawayAction = fmt.Sprintf("%s=%s", "ACTION", model.RunawayActionType(setting.Action).String())
if setting.Watch != nil {
dur := time.Duration(setting.Watch.LastingDurationMs) * time.Millisecond
runawayWatch = fmt.Sprintf("%s=%s[%s]", "WATCH", model.RunawayWatchType(setting.Watch.Type).String(), dur.String())
queryLimit = fmt.Sprintf("%s, %s, %s", runawayRule, runawayAction, runawayWatch)
} else {
queryLimit = fmt.Sprintf("%s, %s", runawayRule, runawayAction)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// convert runaway settings
queryLimit := ""
if setting := group.RunawaySettings; setting != nil {
runawayRule, runawayAction, runawayWatch := "", "", ""
if setting.Rule == nil {
return errors.Errorf("unexpected runaway config in resource group")
}
dur := time.Duration(setting.Rule.ExecElapsedTimeMs) * time.Millisecond
runawayRule = fmt.Sprintf("%s=%s", "EXEC_ELAPSED", dur.String())
runawayAction = fmt.Sprintf("%s=%s", "ACTION", model.RunawayActionType(setting.Action).String())
if setting.Watch != nil {
dur := time.Duration(setting.Watch.LastingDurationMs) * time.Millisecond
runawayWatch = fmt.Sprintf("%s=%s[%s]", "WATCH", model.RunawayWatchType(setting.Watch.Type).String(), dur.String())
queryLimit = fmt.Sprintf("%s, %s, %s", runawayRule, runawayAction, runawayWatch)
} else {
queryLimit = fmt.Sprintf("%s, %s", runawayRule, runawayAction)
}
// convert runaway settings
var builder strings.Builder
if setting := group.RunawaySettings; setting != nil {
if setting.Rule == nil {
return errors.Errorf("unexpected runaway config in resource group")
}
dur := time.Duration(setting.Rule.ExecElapsedTimeMs) * time.Millisecond
builder.WriteString("EXEC_ELAPSED=")
builder.WriteString(dur.String())
builder.WriteString(", ACTION=")
builder.WriteString(model.RunawayActionType(setting.Action).String())
if setting.Watch != nil {
dur := time.Duration(setting.Watch.LastingDurationMs) * time.Millisecond
builder.WriteString(", WATCH=")
builder.WriteString(model.RunawayWatchType(setting.Watch.Type).String())
builder.Write('[')
builder.WriteString(dur.String())
builder.Write(']')
}
}
queryLimit := builder.String()

I think use StringBuilder instead of nested fmt.Sprintf can make the code cleaner, but I'm ok with the current code.

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jun 6, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Jun 6, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: glorv, nolouch

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

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot
Copy link

ti-chi-bot bot commented Jun 6, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-06-05 08:26:38.724841001 +0000 UTC m=+250384.997813787: ☑️ agreed by nolouch.
  • 2023-06-06 10:59:23.687514558 +0000 UTC m=+2255.532149154: ☑️ agreed by glorv.

@ti-chi-bot ti-chi-bot bot added the approved label Jun 6, 2023
@ti-chi-bot ti-chi-bot bot merged commit a26691c into pingcap:master Jun 6, 2023
@CabinfeverB CabinfeverB deleted the resource_manager/runaway_I_S branch June 21, 2023 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants