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: integrate fast create table into normal general DDL workflow #55025

Merged
merged 7 commits into from
Jul 31, 2024

Conversation

D3Hunter
Copy link
Contributor

@D3Hunter D3Hunter commented Jul 29, 2024

What problem does this PR solve?

Issue Number: ref #54436

Problem Summary:

What changed and how does it work?

  • as title, we reuse the variable to enable merging create table jobs in normal general DDL. reason:

Compared with current general DDL, the speedup of fast-create-table mostly due to merging multiple CreateTable jobs into 1 CreateTables job, and running them together and disable wait schema version synchonization. So we have to use a larger concurrency to make them merge as we are merging from the job channel. Without merging jobs, such as without enough concurrency, it's even slower than current general DDL, as it has less workers in most cases. Normal general DDL can merge jobs too.
current fast-create-table is harder to support creating tables with foreign keys without wait schema version change, and without waiting for schema version synced, it causes schema inconsistency for half ddl lease which is expected. Normal general DDL don't have such issues.

  • some code of previous fast-create is still there, will remove them later.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)

same case in #54693, with fast-create flag enabled, takes 9m4. when run with 100 threads, takes 4m20
image

  • 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 do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 29, 2024
Copy link

tiprow bot commented Jul 29, 2024

Hi @D3Hunter. 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.

Copy link

codecov bot commented Jul 29, 2024

Codecov Report

Attention: Patch coverage is 89.62963% with 14 lines in your changes missing coverage. Please review.

Project coverage is 75.4601%. Comparing base (7cdf918) to head (bd257aa).
Report is 29 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #55025        +/-   ##
================================================
+ Coverage   72.8418%   75.4601%   +2.6183%     
================================================
  Files          1560       1566         +6     
  Lines        438616     448047      +9431     
================================================
+ Hits         319496     338097     +18601     
+ Misses        99538      89269     -10269     
- Partials      19582      20681      +1099     
Flag Coverage Δ
integration 51.6245% <40.7407%> (?)
unit 71.6548% <89.6296%> (-0.1904%) ⬇️

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

Components Coverage Δ
dumpling 52.9567% <ø> (ø)
parser ∅ <ø> (∅)
br 63.2278% <ø> (+17.3487%) ⬆️

@D3Hunter D3Hunter mentioned this pull request Jul 30, 2024
75 tasks
@D3Hunter D3Hunter changed the title [WIP]ddl: integrate fast create table into normal general DDL workflow ddl: integrate fast create table into normal general DDL workflow Jul 30, 2024
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 30, 2024
@D3Hunter D3Hunter requested a review from GMHDBJD July 30, 2024 10:30
Copy link
Contributor

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

e.limitJobCh <- task
}
// TODO this might block forever, as the consumer part considers context cancel.
e.limitJobCh <- task
}

// addBatchDDLJobsV1 gets global job IDs and puts the DDL jobs in the DDL queue.
func (d *ddl) addBatchDDLJobsV1(jobWs []*JobWrapper) {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we can revert the name to addBatchDDLJobs in later pr.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lgtm

@@ -10139,19 +10154,20 @@ func (d *ddl) addBatchDDLJobsV1(jobWs []*JobWrapper) {
logutil.DDLLogger().Info("add DDL jobs",
zap.Int("batch count", len(jobWs)),
zap.String("jobs", jobs),
zap.Bool("table", toTable))
zap.Bool("table", toTable),
zap.Bool("fast_create", fastCreate))
}
}

// addBatchLocalDDLJobs gets global job IDs and delivery the DDL jobs to local TiDB
func (d *ddl) addBatchLocalDDLJobs(jobWs []*JobWrapper) {
Copy link
Contributor

Choose a reason for hiding this comment

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

will not be called currently?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, some code are not removed currently, as this pr is quite large, will do it later

Copy link
Contributor

@GMHDBJD GMHDBJD left a comment

Choose a reason for hiding this comment

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

LGTM, remember to update docs

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jul 31, 2024
}
jobs = append(jobs, jobW.Job)
// CreateTables only support tables of same schema now.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we have this limitation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

initial design has this limit #28763

we want to extend it to support tables of different schema, but requires CDC to support it too, maybe in 8.4 or later

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

ti-chi-bot bot commented Jul 31, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-07-31 06:15:29.869476484 +0000 UTC m=+336446.149524547: ☑️ agreed by GMHDBJD.
  • 2024-07-31 10:37:57.311910832 +0000 UTC m=+352193.591958901: ☑️ agreed by tangenta.

Copy link

@yudongusa yudongusa left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

ti-chi-bot bot commented Jul 31, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: GMHDBJD, tangenta, yudongusa

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 the approved label Jul 31, 2024
@ti-chi-bot ti-chi-bot bot merged commit 41bb8f5 into pingcap:master Jul 31, 2024
24 checks passed
@D3Hunter D3Hunter deleted the batch-create branch August 1, 2024 02:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants