-
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
resource_group: support patch for altering resource group #44322
Changes from 38 commits
7fd561b
d9d85e6
ea2546e
e135c5b
378ed64
b620b8d
5aef7a8
9629c5a
8841b19
fc82179
36edf90
834fdfe
b45fe72
97ba6da
4022180
a608efa
ce32af0
e437724
4378b08
1389dcf
1afc266
4d62418
2894b71
4786bfe
62ee255
91f75c7
568224a
1cb8895
baf2563
bce2a1b
a8b5ce6
a40dcce
e868458
041aa43
5475373
d7cd8ed
44cb2b9
e9ecd11
ca5e460
cf54452
54513ed
cc2b3b1
44e268a
244b986
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -14,6 +14,9 @@ | |||||||||
package ast | ||||||||||
|
||||||||||
import ( | ||||||||||
"fmt" | ||||||||||
"strings" | ||||||||||
|
||||||||||
"github.com/pingcap/errors" | ||||||||||
"github.com/pingcap/tidb/parser/auth" | ||||||||||
"github.com/pingcap/tidb/parser/format" | ||||||||||
|
@@ -2160,11 +2163,14 @@ func (n *ResourceGroupOption) Restore(ctx *format.RestoreCtx) error { | |||||||||
ctx.WritePlain("= ") | ||||||||||
ctx.WriteString(n.StrValue) | ||||||||||
case ResourceBurstableOpiton: | ||||||||||
ctx.WriteKeyWord("BURSTABLE") | ||||||||||
ctx.WriteKeyWord("BURSTABLE ") | ||||||||||
ctx.WritePlain("= ") | ||||||||||
ctx.WritePlain(strings.ToUpper(fmt.Sprintf("%v", n.BoolValue))) | ||||||||||
case ResourceGroupRunaway: | ||||||||||
ctx.WritePlain("QUERY_LIMIT") | ||||||||||
ctx.WritePlain(" = ") | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's keep it consistent with others
Suggested change
|
||||||||||
if len(n.ResourceGroupRunawayOptionList) > 0 { | ||||||||||
ctx.WriteKeyWord("QUERY_LIMIT") | ||||||||||
ctx.WritePlain(" = (") | ||||||||||
ctx.WritePlain("(") | ||||||||||
for i, option := range n.ResourceGroupRunawayOptionList { | ||||||||||
if i > 0 { | ||||||||||
ctx.WritePlain(" ") | ||||||||||
|
@@ -2174,6 +2180,8 @@ func (n *ResourceGroupOption) Restore(ctx *format.RestoreCtx) error { | |||||||||
} | ||||||||||
} | ||||||||||
ctx.WritePlain(")") | ||||||||||
} else { | ||||||||||
ctx.WritePlain("NULL") | ||||||||||
} | ||||||||||
default: | ||||||||||
return errors.Errorf("invalid ResourceGroupOption: %d", n.Tp) | ||||||||||
|
@@ -4542,9 +4550,10 @@ func CheckRunawayAppend(ops []*ResourceGroupRunawayOption, newOp *ResourceGroupR | |||||||||
type AlterResourceGroupStmt struct { | ||||||||||
ddlNode | ||||||||||
|
||||||||||
ResourceGroupName model.CIStr | ||||||||||
IfExists bool | ||||||||||
ResourceGroupOptionList []*ResourceGroupOption | ||||||||||
ResourceGroupName model.CIStr | ||||||||||
IfExists bool | ||||||||||
ResourceGroupOptionList []*ResourceGroupOption | ||||||||||
ResourceGroupRunawayOptionList []*ResourceGroupRunawayOption | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why need this field? I see there are already ResourceGroupRunawayOptionList in ResourceGroupOptionList There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. forget to remove it |
||||||||||
} | ||||||||||
|
||||||||||
func (n *AlterResourceGroupStmt) Restore(ctx *format.RestoreCtx) error { | ||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1866,6 +1866,7 @@ const ( | |
RunawayActionDryRun RunawayActionType = iota | ||
RunawayActionCooldown | ||
RunawayActionKill | ||
RunawayNoneAction | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIT: better let this default RunawayNoneAction to be the iota There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Because we do not support patch in the runaway setting clause, it means that the user must declare the configuration of action, but action is just an int and cannot judge nil like a pointer, so this default value can judge whether the user has declared action.
Because there is no RunawayNoneAction in kvproto, I have made RunawayNoneAction equal to 3 to avoid semantic conversion between kvproto and tidb There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When action = RunawayNoneAction, we can just set to ResourceGroupSettings and vice verse, so there is even no need to add this action type here. |
||
) | ||
|
||
// RunawayWatchType is the type of runaway watch. | ||
|
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.
Here are new modifications and add test. @glorv @nolouch @Connor1996
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 this default value is useless