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: fix the optimization for the empty table(speed up) #49629

Merged
merged 1 commit into from
Dec 26, 2023

Conversation

zimulala
Copy link
Contributor

@zimulala zimulala commented Dec 20, 2023

What problem does this PR solve?

Issue Number: close #49679, close #49682

Problem Summary:
The optimization for the empty table(startKey == nil && endKey == nil) doesn't work.
The following case is obvious (because split regions take so long).
#49679

[2023/12/20 11:23:10.873 +08:00] [INFO] [backfilling.go:712] ["start backfill workers to reorg record"] [category=ddl] [type="add index"] [workerCnt=4] [regionCnt=1] [startKey=] [endKey=]
...
[2023/12/20 11:25:14.752 +08:00] [INFO] [backfilling.go:559] ["get backfill range task, get reverse key failed"] [category=ddl] [error="[tikv:9005]Region is unavailable"]
...
...

What changed and how does it work?

Check List

Tests

  • Unit test
  • Integration test
    Before this PR, took time: 2min+
    image

After this PR, took time: 40s+
img_v3_026b_4698de00-e023-4c0a-990d-8cdb530e67bg

  • 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

@zimulala zimulala added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 20, 2023
@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue do-not-merge/needs-tests-checked release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Dec 20, 2023
Copy link

codecov bot commented Dec 20, 2023

Codecov Report

Merging #49629 (8f492a4) into master (210bc42) will increase coverage by 0.7322%.
Report is 82 commits behind head on master.
The diff coverage is 100.0000%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #49629        +/-   ##
================================================
+ Coverage   71.0037%   71.7359%   +0.7322%     
================================================
  Files          1368       1429        +61     
  Lines        399344     430788     +31444     
================================================
+ Hits         283549     309030     +25481     
- Misses        96005     102862      +6857     
+ Partials      19790      18896       -894     
Flag Coverage Δ
integration 45.0807% <100.0000%> (?)
unit 71.0034% <ø> (-0.0003%) ⬇️

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

Components Coverage Δ
dumpling 53.9663% <ø> (ø)
parser ∅ <ø> (∅)
br 46.3262% <ø> (-6.5668%) ⬇️

@ti-chi-bot ti-chi-bot bot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. do-not-merge/needs-linked-issue do-not-merge/needs-tests-checked labels Dec 21, 2023
Comment on lines +391 to +395
if len(startKey) == 0 && len(endKey) == 0 {
logutil.BgLogger().Info("split table range from PD, get noop table range", zap.String("category", "ddl"), zap.Int64("physicalTableID", t.GetPhysicalID()))
return []kv.KeyRange{}, nil
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Why not check this in origin place? Thus we can skip setupWorkers() and consumer.run()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because there will be return an error as described in #49682

@zimulala zimulala changed the title ddl: add empty table handle ddl: fix the optimization for the empty table(speed up) Dec 22, 2023
@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Dec 26, 2023
Copy link

ti-chi-bot bot commented Dec 26, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Defined2014, tangenta

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 ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Dec 26, 2023
Copy link

ti-chi-bot bot commented Dec 26, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-12-26 02:59:47.640626252 +0000 UTC m=+1534678.677853178: ☑️ agreed by tangenta.
  • 2023-12-26 03:05:02.374525063 +0000 UTC m=+1534993.411751990: ☑️ agreed by Defined2014.

@wuhuizuo
Copy link
Contributor

/retest

Copy link

tiprow bot commented Dec 26, 2023

@wuhuizuo: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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/test-infra repository.

@ti-chi-bot ti-chi-bot bot merged commit dc694a1 into pingcap:master Dec 26, 2023
18 checks passed
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-6.5: #49814.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.1: #49815.

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #49816.

@zimulala zimulala changed the title ddl: fix the optimization for the empty table(speed up) ddl: fix the optimization for the empty table(speed up and reduce memory usage) Jan 9, 2024
@zimulala zimulala changed the title ddl: fix the optimization for the empty table(speed up and reduce memory usage) ddl: fix the optimization for the empty table(speed up) Jan 9, 2024
@ti-chi-bot ti-chi-bot added needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. and removed needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. labels Jan 23, 2024
@ti-chi-bot
Copy link
Member

/cherry-pick release-6.5

@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request could not be created: failed to create pull request against pingcap/tidb#release-6.5 from head ti-chi-bot:cherry-pick-49629-to-release-6.5: status code 422 not one of [201], body: {"message":"Validation Failed","errors":[{"resource":"PullRequest","code":"custom","message":"A pull request already exists for ti-chi-bot:cherry-pick-49629-to-release-6.5."}],"documentation_url":"https://docs.github.com/rest/pulls/pulls#create-a-pull-request"}

@ti-chi-bot
Copy link
Member

@ti-chi-bot: new pull request could not be created: failed to create pull request against pingcap/tidb#release-6.5 from head ti-chi-bot:cherry-pick-49629-to-release-6.5: status code 422 not one of [201], body: {"message":"Validation Failed","errors":[{"resource":"PullRequest","code":"custom","message":"A pull request already exists for ti-chi-bot:cherry-pick-49629-to-release-6.5."}],"documentation_url":"https://docs.github.com/rest/pulls/pulls#create-a-pull-request"}

In response to this:

/cherry-pick release-6.5

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 ti-community-infra/tichi repository.

@ti-chi-bot ti-chi-bot removed the needs-cherry-pick-release-6.5 Should cherry pick this PR to release-6.5 branch. label Jan 25, 2024
@zimulala zimulala deleted the zimuxia/empty-tbl branch February 23, 2024 01:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
5 participants