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: schedule as many jobs as possible in one round, simplify sql to query jobs #54438

Merged
merged 5 commits into from
Jul 9, 2024

Conversation

D3Hunter
Copy link
Contributor

@D3Hunter D3Hunter commented Jul 4, 2024

What problem does this PR solve?

Issue Number: ref #54436

Problem Summary:

What changed and how does it work?

  • schedule as many jobs as possible in one round, simplify sql to query jobs
  • replace 2 ddl test hook with failpoint
  • rename methods

Check List

Tests

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

before this pr: create 100K tables under same database on owner on 1pd/3tidb/3tikv using 10 threads, run 2 time, takes 31m16/29m5. avg cpu about [335, 400]

after: run 3 times, takes 32m8/22m56/25m29, avg cpu about [200, 280]. the test result is not stable as expected, seems there are other components interfering DDL process, will check it later. but overall it it's better, both in time and resource usage

  • 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. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jul 4, 2024
Copy link

tiprow bot commented Jul 4, 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.

pkg/ddl/job_table.go Outdated Show resolved Hide resolved
Copy link

codecov bot commented Jul 4, 2024

Codecov Report

Attention: Patch coverage is 80.41237% with 19 lines in your changes missing coverage. Please review.

Project coverage is 56.3967%. Comparing base (be16d49) to head (1edc320).
Report is 29 commits behind head on master.

Additional details and impacted files
@@                Coverage Diff                @@
##             master     #54438         +/-   ##
=================================================
- Coverage   74.7851%   56.3967%   -18.3884%     
=================================================
  Files          1536       1666        +130     
  Lines        361822     614408     +252586     
=================================================
+ Hits         270589     346506      +75917     
- Misses        71592     244564     +172972     
- Partials      19641      23338       +3697     
Flag Coverage Δ
integration 37.2223% <63.9175%> (?)
unit 72.1366% <77.3195%> (-1.5610%) ⬇️

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

Components Coverage Δ
dumpling 52.9656% <ø> (-2.2339%) ⬇️
parser ∅ <ø> (∅)
br 53.0896% <ø> (+5.1741%) ⬆️

@D3Hunter D3Hunter changed the title ddl: schedule as many jobs as possible in one round ddl: schedule as many jobs as possible in one round, simplify sql to query jobs Jul 4, 2024
@ti-chi-bot ti-chi-bot bot added the sig/planner SIG: Planner label Jul 4, 2024
@D3Hunter D3Hunter mentioned this pull request Jul 4, 2024
55 tasks
@D3Hunter
Copy link
Contributor Author

D3Hunter commented Jul 5, 2024

@lance6716

@@ -75,7 +73,7 @@ func TestAddBatchJobError(t *testing.T) {
}

func TestParallelDDL(t *testing.T) {
store, dom := testkit.CreateMockStoreAndDomainWithSchemaLease(t, testLease)
store, _ := testkit.CreateMockStoreAndDomainWithSchemaLease(t, testLease)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
store, _ := testkit.CreateMockStoreAndDomainWithSchemaLease(t, testLease)
store := testkit.CreateMockStoreWithSchemaLease(t, testLease)

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jul 5, 2024
pkg/ddl/job_table.go Show resolved Hide resolved
if wk == nil {
// should not happen, we have checked available() before, and we are
// the only routine consumes worker.
logutil.DDLLogger().Info("no %v worker available now", zap.Stringer("type", targetPool.tp()))
Copy link
Contributor

Choose a reason for hiding this comment

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

no need to use %v

failpoint.InjectCall("beforeRunJobWithWorker")
// runOneJobStep runs one step of the DDL job. we are using online-schema-change,
// one job might go through multiple steps, each step is one job state change such
// as from 'done' -> 'synced, or one schema state change such as 'delete only' -> 'write only'.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// as from 'done' -> 'synced, or one schema state change such as 'delete only' -> 'write only'.
// as from 'done' -> 'synced', or one schema state change such as 'delete only' -> 'write only'.

@@ -641,14 +633,6 @@ func (s *jobScheduler) runJobWithWorker(wk *worker, job *model.Job) error {
return nil
}

func (*jobScheduler) markJobProcessing(se *sess.Session, job *model.Job) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe involve another DDL dev to think about that we don't persist it.

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

ti-chi-bot bot commented Jul 5, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-07-05 05:49:08.862621375 +0000 UTC m=+1562675.348110207: ☑️ agreed by tangenta.
  • 2024-07-05 07:17:00.773897714 +0000 UTC m=+1567947.259386546: ☑️ agreed by lance6716.

Copy link

ti-chi-bot bot commented Jul 5, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hawkingrei, lance6716, 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 the approved label Jul 5, 2024
@D3Hunter
Copy link
Contributor Author

D3Hunter commented Jul 5, 2024

/hold

@ti-chi-bot ti-chi-bot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 5, 2024
@D3Hunter D3Hunter mentioned this pull request Jul 8, 2024
13 tasks
@D3Hunter
Copy link
Contributor Author

D3Hunter commented Jul 9, 2024

/unhold

@ti-chi-bot ti-chi-bot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 9, 2024
@D3Hunter
Copy link
Contributor Author

D3Hunter commented Jul 9, 2024

/retest

Copy link

tiprow bot commented Jul 9, 2024

@D3Hunter: 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-sigs/prow repository.

@ti-chi-bot ti-chi-bot bot merged commit 8c1ce99 into pingcap:master Jul 9, 2024
21 checks passed
@D3Hunter D3Hunter deleted the schedule-amap2 branch July 9, 2024 04:48
@lance6716 lance6716 mentioned this pull request Jul 10, 2024
13 tasks
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. 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