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

[cherry-pick 6327] server: add accelerate-schedule/batch api #6348

Conversation

Lloyd-Pottiger
Copy link
Contributor

Thank you for working on PD! Please read PD's CONTRIBUTING document BEFORE filing this PR.

PR Title Format:

  1. pkg [, pkg2, pkg3]: what's changed
  2. *: what's changed

-->

What problem does this PR solve?

Issue Number: Close #6326

What is changed and how does it work?

add accelerate-schedule/batch api

Check List

Tests

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

Code changes

Side effects

  • Possible performance regression
  • Increased code complexity
  • Breaking backward compatibility

Related changes

Release note

None.

Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>

Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Apr 20, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • bufferflies
  • lhy1024

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/cherry-pick-not-approved needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Apr 20, 2023
@ti-chi-bot
Copy link
Member

Hi @Lloyd-Pottiger. Thanks for your PR.

I'm waiting for a tikv member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@codecov
Copy link

codecov bot commented Apr 20, 2023

Codecov Report

Patch coverage: 78.22% and project coverage change: +0.02 🎉

Comparison is base (7910e2c) 75.65% compared to head (4ba5c21) 75.67%.

❗ Current head 4ba5c21 differs from pull request most recent head 154d785. Consider uploading reports for the commit 154d785 to get more accurate results

Additional details and impacted files
@@               Coverage Diff               @@
##           release-6.5    #6348      +/-   ##
===============================================
+ Coverage        75.65%   75.67%   +0.02%     
===============================================
  Files              330      330              
  Lines            32975    33009      +34     
===============================================
+ Hits             24946    24980      +34     
+ Misses            5881     5876       -5     
- Partials          2148     2153       +5     
Flag Coverage Δ
unittests 75.67% <78.22%> (+0.02%) ⬆️

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

Impacted Files Coverage Δ
server/api/region.go 68.21% <51.51%> (-1.32%) ⬇️
server/cluster/unsafe_recovery_controller.go 82.96% <87.77%> (+4.25%) ⬆️
server/api/router.go 97.96% <100.00%> (+<0.01%) ⬆️

... and 23 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

// @Success 200 {string} string "Accelerate regions scheduling in given ranges [startKey1, endKey1), [startKey2, endKey2), ..."
// @Failure 400 {string} string "The input is invalid."
// @Router /regions/accelerate-schedule/batch [post]
func (h *regionsHandler) AccelerateRegionsScheduleInRanges(w http.ResponseWriter, r *http.Request) {
Copy link
Contributor

Choose a reason for hiding this comment

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

how about exract the same code as function from AccelerateRegionsScheduleInRange?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AccelerateRegionsScheduleInRange is not used anymore, maybe we can remove it later.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the old api can't be remove, you don't know the other compoment has depends on it .

var msgBuilder strings.Builder
msgBuilder.Grow(128)
msgBuilder.WriteString("Accelerate regions scheduling in given ranges: ")
var regions []*core.RegionInfo
Copy link
Contributor

Choose a reason for hiding this comment

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

why not use regionsIDList?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix

h.rd.JSON(w, http.StatusBadRequest, err.Error())
return
}
regions = append(regions, rc.ScanRegions(startKey, endKey, limit)...)
Copy link
Contributor

Choose a reason for hiding this comment

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

what's happened if the regions exist this new region?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not possible, this api is used by partition table, the regions come from different partition tables.

Copy link
Contributor

Choose a reason for hiding this comment

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

but this api has been expose by all people. unless you can ensure only the partition table use it .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is only used by partition table now.
To avoid this, change to use set.

Copy link
Contributor

@bufferflies bufferflies Apr 23, 2023

Choose a reason for hiding this comment

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

It's my mistake, not need to use set, cache TTL is map

pd/pkg/cache/ttl.go

Lines 65 to 68 in 5bdfa71

c.items[key] = ttlCacheItem{
value: value,
expire: time.Now().Add(ttl),
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reverted

Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>
@Lloyd-Pottiger Lloyd-Pottiger force-pushed the release-6.5-add-batch-accelerate-schedule-api branch from 4ba5c21 to 154d785 Compare April 23, 2023 03:37
Copy link
Contributor

@bufferflies bufferflies left a comment

Choose a reason for hiding this comment

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

the reset LGTM

@VelocityLight VelocityLight added cherry-pick-approved Cherry pick PR approved by release team. and removed do-not-merge/cherry-pick-not-approved labels Apr 24, 2023
@ti-chi-bot ti-chi-bot bot deleted a comment from ti-chi-bot Apr 24, 2023
@ti-chi-bot ti-chi-bot bot added the status/LGT1 Indicates that a PR has LGTM 1. label Apr 24, 2023
@lhy1024
Copy link
Contributor

lhy1024 commented Apr 24, 2023

/ok-to-test

@ti-chi-bot ti-chi-bot bot added ok-to-test Indicates a PR is ready to be tested. and removed needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Apr 24, 2023
@ti-chi-bot ti-chi-bot bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Apr 24, 2023
@lhy1024
Copy link
Contributor

lhy1024 commented Apr 24, 2023

/merge

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Apr 24, 2023

@lhy1024: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

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 ti-community-infra/tichi repository.

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Apr 24, 2023

This pull request has been accepted and is ready to merge.

Commit hash: 154d785

@ti-chi-bot ti-chi-bot bot added the status/can-merge Indicates a PR has been approved by a committer. label Apr 24, 2023
@ti-chi-bot ti-chi-bot bot merged commit 10b691a into tikv:release-6.5 Apr 24, 2023
@ti-chi-bot ti-chi-bot removed the cherry-pick-approved Cherry pick PR approved by release team. label Jun 14, 2023
@ti-chi-bot ti-chi-bot added the cherry-pick-approved Cherry pick PR approved by release team. label Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick-approved Cherry pick PR approved by release team. ok-to-test Indicates a PR is ready to be tested. release-note-none Denotes a PR that doesn't merit a release note. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants