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

addindex/disttask: adjust add index task concurrency & add check when submit task #49403

Merged
merged 3 commits into from
Dec 13, 2023

Conversation

D3Hunter
Copy link
Contributor

@D3Hunter D3Hunter commented Dec 13, 2023

What problem does this PR solve?

Issue Number: ref #49008

Problem Summary:

What changed and how does it work?

  • adjust add index task concurrency to make sure it can be scheduled
  • add sanity check that task.Concurrency should < cpu-cpunt when submit task

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. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 13, 2023
Copy link

tiprow bot commented Dec 13, 2023

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

if err != nil {
return 0, nil
}
return writerMemSize / uint64(concurrency) / 10, nil
return writerMemSize / uint64(workerCntLimit) / 10, nil
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ywqzzy should use taskConcurrency? as this worker-cnt might > cpu-count

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes

@D3Hunter D3Hunter changed the title addindex: use saved worker-cnt & adjust add index concurrency addindex: use saved worker-cnt & adjust add index concurrency when run on disttask Dec 13, 2023
require.Equal(t, 1, task.Concurrency)
taskMeta := ddl.BackfillTaskMeta{}
require.NoError(t, json.Unmarshal(task.Meta, &taskMeta))
require.Equal(t, 111, taskMeta.WorkerCntLimit)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why setting workerCntLimit > cpu count? If task concurrency != workerCnt, the reserved resource is less than real consuming resource.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

1 add-index worker might not consume 1 core, so GetDDLReorgWorkerCounter can be larger than core-count, see https://docs.pingcap.com/tidb/stable/system-variables#tidb_ddl_reorg_worker_cnt.

if user do set tidb_ddl_reorg_worker_cnt > core-count, we reserve resource using core-count, and that's what we can reserve the most.

Comment on lines +27 to +33
// ┌──────┐ │ ┌───────┐ ┌──┴───┐
// │failed│ │ ┌────────►│pausing├──────►│paused│
// └──────┘ │ │ └───────┘ └──────┘
// ▼ │
// ┌──────┐ ┌───┴───┐ ┌────────┐
// │pending├────►│running├────►│succeed │
// └──┬────┘ └───┬───┘ └────────┘
// ▼ │ ┌──────────┐
// ┌──────┐ ├────────►│cancelling│
// │failed│ │ └────┬─────┘
// └──────┘ │ ▼
// │ ┌─────────┐ ┌────────┐
// └────────►│reverting├────►│reverted│
// └────┬────┘ └────────┘
// │ ┌─────────────┐
// └─────────►│revert_failed│
// └─────────────┘
// └──┬────┘ └──┬┬───┘ └────────┘
Copy link
Contributor

Choose a reason for hiding this comment

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

when will the task state transform from pending to failed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

invalid task type or dispatcher init failed

@@ -41,21 +40,23 @@ type mergeSortExecutor struct {
cloudStoreURI string
mu sync.Mutex
subtaskSortedKVMeta *external.SortedKVMeta
workerCntLimit int
Copy link
Contributor

@ywqzzy ywqzzy Dec 13, 2023

Choose a reason for hiding this comment

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

In local add index, the workerCnt can be adjusted dynamically.
Need to discuss whether we will support the feature.

Copy link
Contributor

Choose a reason for hiding this comment

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

In local add index, the workerCnt can be adjusted dynamically. Need to discuss whether we will support the feature.

ok for now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In local add index, the workerCnt can be adjusted dynamically.

is this an exposed feature or just previous code can support use newest workerCnt for later subtask?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tangenta
tangenta previously approved these changes Dec 13, 2023
@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Dec 13, 2023
Copy link

codecov bot commented Dec 13, 2023

Codecov Report

Merging #49403 (b7355ad) into master (64430c3) will increase coverage by 0.6752%.
Report is 1 commits behind head on master.
The diff coverage is 0.0000%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #49403        +/-   ##
================================================
+ Coverage   71.0560%   71.7312%   +0.6752%     
================================================
  Files          1368       1414        +46     
  Lines        401362     414964     +13602     
================================================
+ Hits         285192     297659     +12467     
- Misses        96344      98503      +2159     
+ Partials      19826      18802      -1024     
Flag Coverage Δ
integration 43.6428% <0.0000%> (?)
unit 71.0560% <ø> (ø)

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

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

@D3Hunter
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Dec 13, 2023

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

@D3Hunter
Copy link
Contributor Author

/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 Dec 13, 2023
@D3Hunter D3Hunter force-pushed the adjust-add-index-con branch from ccac642 to b971889 Compare December 13, 2023 05:50
@ti-chi-bot ti-chi-bot bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 13, 2023
@ti-chi-bot ti-chi-bot bot removed the approved label Dec 13, 2023
@D3Hunter D3Hunter changed the title addindex: use saved worker-cnt & adjust add index concurrency when run on disttask addindex: adjust add index task concurrency & add check when submit task Dec 13, 2023
@D3Hunter D3Hunter changed the title addindex: adjust add index task concurrency & add check when submit task addindex/disttask: adjust add index task concurrency & add check when submit task Dec 13, 2023
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Dec 13, 2023
Copy link

ti-chi-bot bot commented Dec 13, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-12-13 04:34:54.990302433 +0000 UTC m=+417186.027529364: ☑️ agreed by tangenta.
  • 2023-12-13 05:58:53.033949941 +0000 UTC m=+422224.071176866: ☑️ agreed by ywqzzy.

@D3Hunter D3Hunter requested a review from tangenta December 13, 2023 06:03
Copy link

ti-chi-bot bot commented Dec 13, 2023

[APPROVALNOTIFIER] This PR is APPROVED

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

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 Dec 13, 2023
@D3Hunter
Copy link
Contributor Author

/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 Dec 13, 2023
@ti-chi-bot ti-chi-bot bot merged commit 3379450 into pingcap:master Dec 13, 2023
15 checks passed
@D3Hunter D3Hunter deleted the adjust-add-index-con branch December 13, 2023 08:25
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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants