*: enhance the table regions HTTP API#12357
Merged
sre-bot merged 9 commits intopingcap:masterfrom Sep 26, 2019
Merged
Conversation
disksing
reviewed
Sep 24, 2019
| github.com/pingcap/pd v0.0.0-20190712044914-75a1f9f3062b h1:oS9PftxQqgcRouKhhdaB52tXhVLEP7Ng3Qqsd6Z18iY= | ||
| github.com/pingcap/pd v0.0.0-20190712044914-75a1f9f3062b/go.mod h1:3DlDlFT7EF64A1bmb/tulZb6wbPSagm5G4p1AlhaEDs= | ||
| github.com/pingcap/pd v1.1.0-beta.0.20190923032047-5c648dc365e0 h1:GIEq+wZfrl2bcJxpuSrEH4H7/nlf5YdmpS+dU9lNIt8= | ||
| github.com/pingcap/pd v1.1.0-beta.0.20190923032047-5c648dc365e0/go.mod h1:G/6rJpnYwM0LKMec2rI82/5Kg6GaZMvlfB+e6/tvYmI= |
Contributor
There was a problem hiding this comment.
weird, any idea why it changes to v1.1.0?
Contributor
Author
There was a problem hiding this comment.
I use the latest pd in go.mod
https://github.com/pingcap/tidb/pull/12357/files#diff-37aff102a57d3d7b797f152915a6dc16R44
Codecov Report
@@ Coverage Diff @@
## master #12357 +/- ##
================================================
+ Coverage 79.7501% 80.1081% +0.3579%
================================================
Files 462 462
Lines 101917 103962 +2045
================================================
+ Hits 81279 83282 +2003
- Misses 14773 14818 +45
+ Partials 5865 5862 -3 |
disksing
reviewed
Sep 25, 2019
Contributor
Author
|
/run-all-tests |
Contributor
Author
|
/run-all-tests |
Contributor
Author
1 similar comment
Contributor
Author
Contributor
|
Your auto merge job has been accepted, waiting for 12348 |
Contributor
|
/run-all-tests |
Contributor
|
@tiancaiamao merge failed. |
Contributor
Author
|
/run-integration-common-test |
Contributor
|
/merge |
Contributor
|
/run-all-tests |
tiancaiamao
added a commit
to tiancaiamao/tidb
that referenced
this pull request
Nov 25, 2019
sre-bot
pushed a commit
that referenced
this pull request
Nov 25, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
This API is used to get the table regions http://localhost:10080/tables/{DB}/{Table}/regions
In current implementation,
getRegionsMetais used to get the region information.That function first gets the regions in the key range, and then call
GetRegionByIDone by one for each region id.The problem is that when the table is huge, it contains so many regions, calling the API is very slow because current implementation visits PD for each region.
What is changed and how it works?
Use
ScanRegionsAPI to implement http://localhost:10080/tables/{DB}/{Table}/regionsScanRegions accepts a key range and returns the region information, we need just one call to get the result instead of calling
GetRegionByIDfor every region.See also tikv/pd#1700 tikv/pd#1699
Check List
Tests
I test it manually on TiKV.
Split the table to get more regions:
See the table regions:
Compare it with the result from the HTTP API: