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: dynamically adjusting the max write speed of reorganization job #57611

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

fzzf678
Copy link
Contributor

@fzzf678 fzzf678 commented Nov 21, 2024

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

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

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

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. sig/planner SIG: Planner size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 21, 2024
Copy link

tiprow bot commented Nov 21, 2024

Hi @fzzf678. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

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.

@fzzf678
Copy link
Contributor Author

fzzf678 commented Nov 21, 2024

/ok-to-test

@ti-chi-bot ti-chi-bot bot added the ok-to-test Indicates a PR is ready to be tested. label Nov 21, 2024
@fzzf678
Copy link
Contributor Author

fzzf678 commented Nov 21, 2024

/test all

Copy link

codecov bot commented Nov 21, 2024

Codecov Report

Attention: Patch coverage is 60.92715% with 59 lines in your changes missing coverage. Please review.

Project coverage is 74.7431%. Comparing base (fe1b9ed) to head (1f9a46c).
Report is 7 commits behind head on master.

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     
Flag Coverage Δ
integration 49.4225% <25.1655%> (?)
unit 72.1905% <55.6291%> (-0.0215%) ⬇️

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

Components Coverage Δ
dumpling 52.7673% <ø> (ø)
parser ∅ <ø> (∅)
br 61.0268% <ø> (+15.5679%) ⬆️
---- 🚨 Try these New Features:

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Nov 22, 2024
@@ -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.
Copy link
Member

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

Copy link
Contributor Author

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

Copy link
Member

@CbcWestwolf CbcWestwolf 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

pkg/meta/model/reorg.go Outdated Show resolved Hide resolved
Copy link

ti-chi-bot bot commented Nov 22, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: CbcWestwolf, winoros
Once this PR has been reviewed and has the lgtm label, please assign gmhdbjd for approval. For more information see the Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Nov 22, 2024
Copy link

ti-chi-bot bot commented Nov 22, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-11-22 06:03:08.187779729 +0000 UTC m=+184375.807434246: ☑️ agreed by winoros.
  • 2024-11-22 06:33:40.782162927 +0000 UTC m=+186208.401817441: ☑️ agreed by CbcWestwolf.

Co-authored-by: CbcWestwolf <1004626265@qq.com>
@fzzf678
Copy link
Contributor Author

fzzf678 commented Nov 22, 2024

/cc @lance6716, please help take a look

@@ -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()
Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor

Choose a reason for hiding this comment

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

{"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

Copy link
Contributor Author

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

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

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 guess an old cluster without DDLReorgMeta field upgrade to a new cluster, after unmarshal, this dm can be nil

Copy link
Contributor Author

@fzzf678 fzzf678 Nov 22, 2024

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

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

Copy link
Contributor Author

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() {
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

update in 50c4334, PTAL

case core.AlterDDLJobMaxWriteSpeed:
if opt.Value != nil {
cons := opt.Value.(*expression.Constant)
speed, err := units.RAMInBytes(cons.Value.GetString())
Copy link
Contributor

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 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 Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. ok-to-test Indicates a PR is ready to be tested. release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner 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