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

region: Add accelerate regions schedule API #2599

Merged
merged 2 commits into from
Jul 6, 2020

Conversation

Yisaer
Copy link
Contributor

@Yisaer Yisaer commented Jul 1, 2020

Add one new region HTTP API.

What problem does this PR solve?

close #2593

What is changed and how it works?

Add one new region related http api to accelerate regions schedule by given key range.

Check List

Tests

  • Unit test

Related changes

  • Need to cherry-pick to the release branch

Release note

  • Support Region HTTP API to promote regions schedule by given key range

@Yisaer Yisaer marked this pull request as draft July 1, 2020 12:56
// @Success 200 {object} string
// @Failure 400 {string} string "The input is invalid."
// @Router /regions/keys/promote [get]
func (h *regionsHandler) PromoteRegionsInRange(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.

I think promote is kind ambiguous, especially we already use the term for the meaning of promote a learner peer to voter.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could it be better to accept hex formatted keys?

Copy link
Contributor Author

@Yisaer Yisaer Jul 2, 2020

Choose a reason for hiding this comment

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

@disksing It's ok to me to change the API/function name here and do you know the API examples in the repo to know about the better format to accept hex formatted keys?

Copy link
Member

Choose a reason for hiding this comment

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

I think maybe you can refer to parseKey in region_command.go?

Copy link
Contributor Author

@Yisaer Yisaer Jul 3, 2020

Choose a reason for hiding this comment

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

@disksing Do you think we need to add a format parameter and support multi key formats here?

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO, hex format is enough because it is our preferred format in the future. Of course, supporting more formats won't make it worse.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for clarifying.

@Yisaer Yisaer changed the title [WIP] region: Add promote regions schedule API [WIP] region: Add accelerate regions schedule API Jul 2, 2020
@Yisaer
Copy link
Contributor Author

Yisaer commented Jul 2, 2020

/run-all-tests

@Yisaer Yisaer requested a review from disksing July 2, 2020 07:59
@Yisaer Yisaer marked this pull request as ready for review July 2, 2020 08:28
@Yisaer Yisaer added the component/api HTTP API. label Jul 2, 2020
@Yisaer Yisaer changed the title [WIP] region: Add accelerate regions schedule API region: Add accelerate regions schedule API Jul 2, 2020
@rleungx
Copy link
Member

rleungx commented Jul 2, 2020

I think #2524 wants to solve a similar problem. Maybe we can find a common way to do it?

@disksing
Copy link
Contributor

disksing commented Jul 2, 2020

I think #2524 wants to solve a similar problem. Maybe we can find a common way to do it?

IMO not very alike.

@disksing
Copy link
Contributor

disksing commented Jul 2, 2020

Basically LGTM. But I wonder if we need to support a large number of regions in the range. One optimization method is to directly save the range, and then scan the range with higher priority first when scanning.

return
}

limit := defaultRegionLimit
Copy link
Contributor

Choose a reason for hiding this comment

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

16 seems to small

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@disksing Do you have any advice? What about 256?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good to me

@@ -148,6 +148,7 @@ func createRouter(ctx context.Context, prefix string, svr *server.Server) *mux.R
clusterRouter.HandleFunc("/regions/check/hist-size", regionsHandler.GetSizeHistogram).Methods("GET")
clusterRouter.HandleFunc("/regions/check/hist-keys", regionsHandler.GetKeysHistogram).Methods("GET")
clusterRouter.HandleFunc("/regions/sibling/{id}", regionsHandler.GetRegionSiblings).Methods("GET")
clusterRouter.HandleFunc("/regions/keys/accelerate-schedule", regionsHandler.AccelerateRegionsScheduleInRange).Methods("POST")
Copy link
Contributor

Choose a reason for hiding this comment

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

could regions/accelerate-schedule be bettter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated.

for _, region := range regions {
regionsIDList = append(regionsIDList, region.GetID())
}
rc.AddSuspectRegions(regionsIDList...)
Copy link
Contributor

Choose a reason for hiding this comment

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

What will happen if repeatedly adding the same regions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The duplicated operators would be discarded due to checkAddOperator (due to same priority) in AddWaitingOperator if the operators added in the first time haven't been successes yet. Is that true? @disksing

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 true.

@Yisaer
Copy link
Contributor Author

Yisaer commented Jul 6, 2020

@rleungx @disksing Ready to be reviewed.

server/api/region.go Outdated Show resolved Hide resolved
@Yisaer
Copy link
Contributor Author

Yisaer commented Jul 6, 2020

/run-test

@Yisaer
Copy link
Contributor Author

Yisaer commented Jul 6, 2020

/run-all-test

@Yisaer Yisaer requested a review from rleungx July 6, 2020 08:26
@lhy1024
Copy link
Contributor

lhy1024 commented Jul 6, 2020

/merge

@ti-srebot
Copy link
Contributor

Sorry @lhy1024, you don't have permission to trigger auto merge event on this branch. The number of LGTM for this PR is 0 while it needs 2 at least

Copy link
Contributor

@lhy1024 lhy1024 left a comment

Choose a reason for hiding this comment

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

LGTM

@lhy1024
Copy link
Contributor

lhy1024 commented Jul 6, 2020

/merge

@ti-srebot
Copy link
Contributor

Sorry @lhy1024, you don't have permission to trigger auto merge event on this branch. The number of LGTM for this PR is 0 while it needs 2 at least

@lhy1024
Copy link
Contributor

lhy1024 commented Jul 6, 2020

LGTM

@ti-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Jul 6, 2020
@ti-srebot
Copy link
Contributor

@lhy1024,Thanks for your review.

@lhy1024
Copy link
Contributor

lhy1024 commented Jul 6, 2020

/merge

@ti-srebot
Copy link
Contributor

Sorry @lhy1024, you don't have permission to trigger auto merge event on this branch. The number of LGTM for this PR is 1 while it needs 2 at least

@rleungx
Copy link
Member

rleungx commented Jul 6, 2020

LGTM

@ti-srebot ti-srebot removed the status/LGT1 Indicates that a PR has LGTM 1. label Jul 6, 2020
@ti-srebot
Copy link
Contributor

@rleungx,Thanks for your review.

@ti-srebot ti-srebot added the status/LGT2 Indicates that a PR has LGTM 2. label Jul 6, 2020
@Yisaer Yisaer added the status/can-merge Indicates a PR has been approved by a committer. label Jul 6, 2020
@ti-srebot
Copy link
Contributor

Sorry @Yisaer, you don't have permission to trigger auto merge event on this branch. You are not a committer or co-leader or leader for the related sigs:scheduling(slack).

@rleungx
Copy link
Member

rleungx commented Jul 6, 2020

/merge

@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot
Copy link
Contributor

@Yisaer merge failed.

@Yisaer
Copy link
Contributor Author

Yisaer commented Jul 6, 2020

/run-integration-ddl-test

@Yisaer Yisaer merged commit 9f1a55c into tikv:master Jul 6, 2020
@Yisaer Yisaer added the needs-cherry-pick-release-4.0 The PR needs to cherry pick to release-4.0 branch. label Jul 29, 2020
@Yisaer
Copy link
Contributor Author

Yisaer commented Jul 29, 2020

/run-cherry-picker

ti-srebot pushed a commit to ti-srebot/pd that referenced this pull request Jul 29, 2020
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-4.0 in PR #2687

Yisaer added a commit that referenced this pull request Jul 29, 2020
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>

Co-authored-by: Song Gao <disxiaofei@163.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/api HTTP API. needs-cherry-pick-release-4.0 The PR needs to cherry pick to release-4.0 branch. 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.

Add API to check regions that belong to a range with higher priority
5 participants