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

api: add a new scheduler to balance the regions of the given key range #8988

Merged
merged 14 commits into from
Feb 10, 2025

Conversation

bufferflies
Copy link
Contributor

What problem does this PR solve?

Issue Number: Close #8987

What is changed and how does it work?

Check List

Tests

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

Code changes

Side effects

Related changes

Release note

None.

Signed-off-by: 童剑 <1045931706@qq.com>
Signed-off-by: 童剑 <1045931706@qq.com>
Copy link
Contributor

ti-chi-bot bot commented Jan 10, 2025

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates the PR's author has signed the dco. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 10, 2025
Signed-off-by: 童剑 <1045931706@qq.com>
Signed-off-by: 童剑 <1045931706@qq.com>
Copy link

codecov bot commented Jan 13, 2025

Codecov Report

Attention: Patch coverage is 61.74242% with 101 lines in your changes missing coverage. Please review.

Project coverage is 76.22%. Comparing base (c92da83) to head (33c12bd).
Report is 1 commits behind head on master.

❌ Your patch status has failed because the patch coverage (61.74%) is below the target coverage (74.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8988      +/-   ##
==========================================
- Coverage   76.23%   76.22%   -0.02%     
==========================================
  Files         467      468       +1     
  Lines       71155    71415     +260     
==========================================
+ Hits        54247    54436     +189     
- Misses      13515    13575      +60     
- Partials     3393     3404      +11     
Flag Coverage Δ
unittests 76.22% <61.74%> (-0.02%) ⬇️

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

@bufferflies bufferflies force-pushed the balance_key_range branch 2 times, most recently from fe71a54 to cb8a4b9 Compare January 14, 2025 08:21
Signed-off-by: 童剑 <1045931706@qq.com>
@bufferflies bufferflies marked this pull request as ready for review January 14, 2025 09:56
@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 Jan 14, 2025
type balanceKeyRangeSchedulerConfig struct {
syncutil.RWMutex
schedulerConfig
balanceKeyRangeSchedulerParam
Copy link
Member

Choose a reason for hiding this comment

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

Shall we use a slice to support multiple key ranges with different roles or engines?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need to support a multi-key range with same role and engine.

Signed-off-by: 童剑 <1045931706@qq.com>
@@ -374,6 +375,17 @@ func NewBalanceWitnessSchedulerCommand() *cobra.Command {
return c
}

// NewBalanceRangeSchedulerCommand returns a command to add a balance-key-range-scheduler.
func NewBalanceRangeSchedulerCommand() *cobra.Command {
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to support it? It's hard to use.

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, it's helpful to debug it in the first step, and then it recommends the SQL function description

Copy link
Member

Choose a reason for hiding this comment

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

How about using API to test now? I don't think we need to add a new command that's going to be deprecated soon.

Signed-off-by: 童剑 <1045931706@qq.com>
@bufferflies bufferflies changed the title api: add new scheduler for balance the regions of the given key range api: add a new scheduler to balance the regions of the given key range Jan 17, 2025
Signed-off-by: 童剑 <1045931706@qq.com>
Signed-off-by: 童剑 <1045931706@qq.com>
Engine string `json:"engine"`
Timeout time.Duration `json:"timeout"`
Ranges []core.KeyRange `json:"ranges"`
TableName string `json:"table-name"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Name it as alias for better, since pd does not understand the table concept.

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.

done

Copy link
Member

@rleungx rleungx left a comment

Choose a reason for hiding this comment

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

The rest LGTM except the left comment.

Use: "balance-range-scheduler [--format=raw|encode|hex] <engine> <role> <table-name> <start_key> <end_key>",
Short: "add a scheduler to balance region for given range",
Run: addSchedulerForBalanceRangeCommandFunc,
Deprecated: "balance-range will be deprecated in the future, please use sql instead",
Copy link
Member

Choose a reason for hiding this comment

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

It's strange to add Deprecated 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.

removed and add one todo for sql implement

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jan 23, 2025
@ti-chi-bot ti-chi-bot bot added the approved label Jan 23, 2025
Signed-off-by: 童剑 <1045931706@qq.com>
Signed-off-by: 童剑 <1045931706@qq.com>
Signed-off-by: 童剑 <1045931706@qq.com>
Signed-off-by: 童剑 <1045931706@qq.com>
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Feb 10, 2025
Copy link
Contributor

ti-chi-bot bot commented Feb 10, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nolouch, rleungx

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

Copy link
Contributor

ti-chi-bot bot commented Feb 10, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-01-23 09:15:28.807279505 +0000 UTC m=+345056.138198909: ☑️ agreed by rleungx.
  • 2025-02-10 08:50:50.910522013 +0000 UTC m=+260093.306744076: ☑️ agreed by nolouch.

@ti-chi-bot ti-chi-bot bot merged commit 517afe0 into tikv:master Feb 10, 2025
23 of 25 checks passed
@bufferflies bufferflies deleted the balance_key_range branch February 11, 2025 06:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved dco-signoff: yes Indicates the PR's author has signed the dco. lgtm 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

api: add new scheduler for balance the regions of the given key range
4 participants