-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
ddl, I_S: support runaway attribute in resource group #43877
Conversation
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]>
Signed-off-by: Cabinfever_B <[email protected]>
[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 The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
Skipping CI for Draft Pull Request. |
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]>
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]> address comment Signed-off-by: Cabinfever_B <[email protected]> address comment 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]>
/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)") |
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.
It occurs to me that as we can pass any duration to EXEC_ELAPSED_IN_SEC
, does IN_SEC
make any sense?
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.
I agree. EXEC_ELAPSED
is better. @songrijie
executor/infoschema_reader.go
Outdated
queryLimit := "" | ||
if setting := group.RunawaySettings; setting != nil { | ||
runawayRule, runawayAction, runawayWatch := "", "", "" | ||
if setting.Rule != nil { |
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.
Seems if rule == nil, the output will format it with a " ," which seems weird to me.
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.
Rule should never be nil. Currently, we only have ExecElapsed
in Rule, and I check it in NewGroupFromOptions
.
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.
Then I suggest remove this check or change it to check setting.Rule == nil and return error directly in this case.
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.
lgtm
Signed-off-by: Cabinfever_B <[email protected]>
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.
LGTM
// 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) | ||
} |
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.
// 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.
[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 |
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
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.