pingcap / pingcap/tidb

A smarter way to scatter batch regions

Open
#33,937 4 comments 0 reactions 0 assignees View on GitHub
component/br component/lightning component/pd type/enhancement
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Enhancement
Both Lightning and BR will do batch split & scatter regions job to make the data import evenly. but this seems not work as expected when we have lots of stores(100+).

basic there are three reasons:
1. We are not get promised the scatter will successfully when batch_size is large.
2. In most cases there's only one region(region_id=2) after cluster bootstrapped
3. Especially for BR, the origin region is not scattered after one batch operation. https://github.com/pingcap/tidb/blob/951bc42d3fca8908be10483ba2ee5884b6635121/br/pkg/restore/split_client.go#L436

According to the metrics. we can see that when request a 8k regions scatter. there are half(4.4k) failed to scatter.
image

To solve this issue.I think we can do a pre-split/scatter job.

Suppose we have lots of stores(100+) and we know the a batch split/scatter size is 8k. we can do the following things

1. Sort 8k split keys.
2. Choose the middle keys according to store count(suppose is 100, then we choose 99 keys can generate 100 parts).
3. Split the region with the chosen 100 keys, and make sure these new split regions scatter successfully.
4. For each rest part. Re-scan the new region with the part min/max keys.
5. Finish the rest split and scatter.

With this change. we can make the full use of tikv store. make each of them do split scatter evenly.

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.