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

disttask: subtasks rebalance during task execution #48306

Merged
merged 32 commits into from
Nov 30, 2023

Conversation

ywqzzy
Copy link
Contributor

@ywqzzy ywqzzy commented Nov 6, 2023

What problem does this PR solve?

Issue Number: ref #48795 close #47298

Problem Summary:
See issue #47298

What is changed and how it works?

RebalanceSubtasks process flow:

  1. find out nodes need to clean subtasks.
  2. get subtasks for each node before scaling out.
  3. group subtasks for each scheduler.
  4. prepare subtasks that need to rebalance to other nodes.
  5. rebalance subtasks to other nodes.
  6. rebalance rest subtasks evenly to liveNodes.
  7. update subtasks and do clean up logic.

Behavior:
see ut in rebalance_test.go

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.
  1. first run on 1 tidb then scale out 1 tidb.
image
  1. from 2 tidb to 1 tidb
image image
  1. from 1 tidb to 3 tidb
image image
  1. from 3 tidb to 1 tidb
image image

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/needs-linked-issue do-not-merge/needs-tests-checked release-note-none size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Nov 6, 2023
Copy link

tiprow bot commented Nov 6, 2023

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

@ti-chi-bot ti-chi-bot bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Nov 6, 2023
Copy link

codecov bot commented Nov 6, 2023

Codecov Report

Merging #48306 (a9085c2) into master (333e8c3) will increase coverage by 1.5864%.
Report is 3 commits behind head on master.
The diff coverage is 0.0000%.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #48306        +/-   ##
================================================
+ Coverage   70.9893%   72.5757%   +1.5864%     
================================================
  Files          1368       1391        +23     
  Lines        404075     412255      +8180     
================================================
+ Hits         286850     299197     +12347     
+ Misses        97242      94193      -3049     
+ Partials      19983      18865      -1118     
Flag Coverage Δ
integration 43.9004% <0.0000%> (?)
unit 70.9929% <ø> (+0.0036%) ⬆️

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

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

@ywqzzy ywqzzy changed the title disttask: fix subtasks unbalanced when node restart [WIP] disttask: fix subtasks unbalanced when node restart Nov 7, 2023
@ti-chi-bot ti-chi-bot bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 7, 2023
@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 17, 2023
@ywqzzy ywqzzy changed the title [WIP] disttask: fix subtasks unbalanced when node restart [WIP] disttask: rebalance subtasks Nov 23, 2023
@ywqzzy ywqzzy changed the title [WIP] disttask: rebalance subtasks [WIP] disttask: subtasks rebalance during task execution Nov 23, 2023
@ti-chi-bot ti-chi-bot bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 23, 2023
@ywqzzy ywqzzy changed the title [WIP] disttask: subtasks rebalance during task execution disttask: subtasks rebalance during task execution Nov 23, 2023
@ywqzzy
Copy link
Contributor Author

ywqzzy commented Nov 29, 2023

/cc @tangenta

@ti-chi-bot ti-chi-bot bot requested a review from tangenta November 29, 2023 07:20
Copy link
Collaborator

@Benjamin2037 Benjamin2037 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 Nov 29, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-11-28 09:35:44.560812451 +0000 UTC m=+915373.226038645: ☑️ agreed by D3Hunter.
  • 2023-11-29 15:31:55.598954008 +0000 UTC m=+1023144.264180204: ☑️ agreed by Benjamin2037.

Copy link
Contributor

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

// When no tidb scale-in/out and averageSubtaskCnt*len(d.LiveNodes) < len(subtasks),
// no need to send subtask to other nodes.
// eg: tidb1 with 3 subtasks, tidb2 with 2 subtasks, subtasks are balanced now.
if averageSubtaskCnt*len(d.LiveNodes) < len(subtasks) && len(d.TaskNodes) == len(d.LiveNodes) {
Copy link
Contributor

Choose a reason for hiding this comment

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

averageSubtaskCnt*len(d.LiveNodes) < len(subtasks) seems to be always true?

Copy link
Contributor Author

@ywqzzy ywqzzy Nov 30, 2023

Choose a reason for hiding this comment

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

No, eg:
tidb1: 4 subtasks, tidb2: 2 subtasks, then average = 3,
average * len(liveNodes) = 6 = len(subtasks)

@ywqzzy
Copy link
Contributor Author

ywqzzy commented Nov 30, 2023

/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 Nov 30, 2023
Copy link

ti-chi-bot bot commented Nov 30, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Benjamin2037, D3Hunter, 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

@ywqzzy
Copy link
Contributor Author

ywqzzy commented Nov 30, 2023

/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 Nov 30, 2023
@ti-chi-bot ti-chi-bot bot merged commit ef02d72 into pingcap:master Nov 30, 2023
15 checks passed
@ti-chi-bot
Copy link
Member

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

ti-chi-bot pushed a commit to ti-chi-bot/tidb that referenced this pull request Nov 30, 2023
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
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.5 release-note-none 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.

subtask can't be re-assigned back when tidb node restart
5 participants