tikv / tikv/pd

api,pd-ctl: support endKey in ScanRegions http interface

Open
#4,400 0 comments 0 reactions 0 assignees View on GitHub
type/enhancement
Dominant language
Go
Stars
1.2k
Forks
783
Avg merge
5d 21h
Merged PRs (30d)
36

Description

## Development Task
Tracking Issue: pingcap/tidb/pull/28330

Support endKey in http interface `regions/key` and adjust the pdctl region command `region startKey` to `region keys`accordingly. This is originally proposed as a precondition of the push down optimisation of `infomation_schema.tikv_region_status`.
- [x] support endKey in `ScanRegions` http interface tikv/pd/pull/4142
- [x] supplement `ScanRegions` http interface tikv/pd/pull/4371
- [ ] relevant docs pingcap/docs/pull/6951
- [x] relevant docs-cn pingcap/docs-cn/pull/7637
- [x] docs-cn typo pingcap/docs-cn/pull/8485

Previous code is involved in v5.4.0.
In the current [implementation](https://github.com/tikv/pd/blob/318f9ceddcb0a35a5a61a2121741a251c85064ec/server/api/region.go#L326) of `scanRegions` , the default limit is `defaultRegionLimit(16)` without `endkey` and `noRegionLimit(-1)` with `endkey`.
> Use this command to query all Regions in a given range [startkey, endkey). It supports range without endKey, the default value of limit is 16 without endKey and -1 (no limit) with endKey.

* When one try to use `startKey = a`, `endKey = ""` try to get all regions in `[a, )`, the default limit is `defaultRegionLimit(16)`, need to set `limit = -1` to get all regions, this is inconsistent with the case where `endKey` is not empty.
* No default limit when using pd-ctl to query `endKey` may cause a lot of network IO cost.

For these two reasons, tend to set the default limit with `endKey` to `defaultRegionLimit(16)` the same as without `endKey`. One can set `limit = -1` to get all regions.

- [x] code pr #4674
- [x] doc-cn pingcap/docs-cn/pull/8607
- [ ] doc update it's added here pingcap/docs/pull/6951

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.