-
Notifications
You must be signed in to change notification settings - Fork 728
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 new api to get the distribution of regions #9090
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: 童剑 <[email protected]>
Skipping CI for Draft Pull Request. |
84099f2
to
66d6daa
Compare
Signed-off-by: 童剑 <[email protected]>
66d6daa
to
e38effa
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #9090 +/- ##
==========================================
+ Coverage 76.25% 76.30% +0.04%
==========================================
Files 468 468
Lines 71695 71850 +155
==========================================
+ Hits 54673 54823 +150
+ Misses 13610 13595 -15
- Partials 3412 3432 +20
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
313f5b1
to
3bc276d
Compare
3bc276d
to
055401d
Compare
Signed-off-by: 童剑 <[email protected]>
055401d
to
dee04ba
Compare
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: lhy1024 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 |
[LGTM Timeline notifier]Timeline:
|
@@ -38,6 +38,7 @@ const ( | |||
store = "/pd/api/v1/store" | |||
Stores = "/pd/api/v1/stores" | |||
StatsRegion = "/pd/api/v1/stats/region" | |||
DistributionRegion = "/pd/api/v1/distributions/region" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about "/pd/api/v1/regions/distribution"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep the style with the "/pd/api/v1/stats/region"
@@ -2169,8 +2169,12 @@ func (c *RaftCluster) PutMetaCluster(meta *metapb.Cluster) error { | |||
} | |||
|
|||
// GetRegionStatsByRange returns region statistics from cluster. | |||
func (c *RaftCluster) GetRegionStatsByRange(startKey, endKey []byte) *statistics.RegionStats { | |||
return statistics.GetRegionStats(c.ScanRegions(startKey, endKey, -1)) | |||
// if useHotFlow is true, the hot region statistics will be returned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the new sql grama "show table t1 partition(p0,p1)" will use it.
server/cluster/cluster.go
Outdated
if useHotFlow { | ||
return statistics.GetRegionStats(c.ScanRegions(startKey, endKey, -1), c, opts...) | ||
} | ||
return statistics.GetRegionStats(c.ScanRegions(startKey, endKey, -1), nil, opts...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need pagination
// @Produce json | ||
// @Success 200 {object} statistics.RegionStats | ||
// @Router /distributions/region [get] | ||
func (h *statsHandler) GetRegionDistributions(w http.ResponseWriter, r *http.Request) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this API is almost the same as GetRegionStatusByKeyRange, why not extend the existing API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine, but this api is already complex. It needs to consider three scenes such as:
- the informations of the regions.
- only needs the region count for
spilt regions
SQL or Tiflash. - the informations of the regions includes the hot statistics
StoreLeaderKeys: make(map[uint64]int64), | ||
StorePeerSize: make(map[uint64]int64), | ||
StorePeerKeys: make(map[uint64]int64), | ||
StoreLeaderCount: make(map[uint64]int), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any OOM risk?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The length of the map is mostly small(less than 200). The API is primarily used by DBAs with a low frequent usage rate.
Signed-off-by: 童剑 <[email protected]>
Signed-off-by: 童剑 <[email protected]>
What problem does this PR solve?
Issue Number: Close #9089
What is changed and how does it work?
Check List
Tests
Code changes
Side effects
Related changes
Release note