-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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: dynamically adjusting the max write speed of reorganization job #57611
base: master
Are you sure you want to change the base?
Conversation
Hi @fzzf678. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with I understand the commands that are listed here. 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 kubernetes-sigs/prow repository. |
/ok-to-test |
/test all |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #57611 +/- ##
================================================
+ Coverage 72.8112% 74.7431% +1.9318%
================================================
Files 1676 1721 +45
Lines 463677 472929 +9252
================================================
+ Hits 337609 353482 +15873
+ Misses 105228 97195 -8033
- Partials 20840 22252 +1412
Flags with carried forward coverage won't be shown. Click here to find out more.
|
@@ -75,8 +75,9 @@ type DDLReorgMeta struct { | |||
// These two variables are used to control the concurrency and batch size of the reorganization process. | |||
// They can be adjusted dynamically through `admin alter ddl jobs` command. | |||
// Note: Don't get or set these two variables directly, use the functions instead. |
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.
Please make these 3 var private
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.
OK, I will try make these vars private in next PR
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.
Rest LGTM
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: CbcWestwolf, winoros The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
Co-authored-by: CbcWestwolf <1004626265@qq.com>
/cc @lance6716, please help take a look |
pkg/planner/core/planbuilder.go
Outdated
@@ -5940,6 +5941,16 @@ func checkAlterDDLJobOptValue(opt *AlterDDLJobOpt) error { | |||
return fmt.Errorf("the value %v for %s is out of range [%v, %v]", | |||
bs, opt.Name, variable.MinDDLReorgBatchSize, variable.MaxDDLReorgBatchSize) | |||
} | |||
case AlterDDLJobMaxWriteSpeed: | |||
speedStr := opt.Value.(*expression.Constant).Value.GetString() |
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 found there's a test case
admin alter ddl jobs 1 max_write_speed = 4
So the value may not be string type? GetString
will not work
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.
We only support the string type with quotation marks
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.
tidb/pkg/parser/parser_test.go
Line 548 in bc03ed8
{"admin alter ddl jobs 1 max_write_speed = 4", true, "ADMIN ALTER DDL JOBS 1 max_write_speed = 4"}, |
Maybe you should change the parser syntax to only accept string
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.
support int in 7d46d9e
// GetMaxWriteSpeedOrDefault gets the max write speed from DDLReorgMeta. | ||
// 0 means no limit. | ||
func (dm *DDLReorgMeta) GetMaxWriteSpeedOrDefault(defaultVal int) int { | ||
if dm == 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.
in which case dm
is nil? And we should handle nil
dm
in SetMaxWriteSpeed
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 guess an old cluster without DDLReorgMeta
field upgrade to a new cluster, after unmarshal, this dm can be 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.
update in 7345329
} | ||
|
||
// GetLimiterSpeed returns the speed of the write limiter. | ||
func (local *Backend) GetLimiterSpeed() int { |
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.
write a unit test to check they are concurrent-safe
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.
Do you mean like this 8c07af0 ?
err := pipe.Execute() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// Adjust worker pool size dynamically. | ||
// Adjust worker pool size and max write speed dynamically. | ||
if job != nil { | ||
go func() { |
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.
this is a problem in old code: We'd better wait the goroutine exited before leave this function, avoid the goroutine accesses something and causes data race with caller.
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.
update in 50c4334, PTAL
pkg/executor/operate_ddl_jobs.go
Outdated
case core.AlterDDLJobMaxWriteSpeed: | ||
if opt.Value != nil { | ||
cons := opt.Value.(*expression.Constant) | ||
speed, err := units.RAMInBytes(cons.Value.GetString()) |
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.
ditto
What problem does this PR solve?
Issue Number: ref #57526 #57229
Problem Summary: See #57229
What changed and how does it work?
Supply later
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.