Empty regions do not merge

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 空region不合并

| username: wakaka

[TiDB Usage Environment] Online
[TiDB Version] v5.0.6
[Encountered Problem] A large number of regions around 1M are not merging
[Reproduction Path] What operations were performed to cause the problem
[Problem Phenomenon and Impact]
Empty regions cannot be recycled. Most of the empty regions belong to tables without data, but enable-cross-table-merge has been enabled. I don’t know why they are not merging.



[Attachment]

| username: Kongdom | Original post link

Refer to this link for more information:

| username: Kongdom | Original post link

The enable-cross-table-merge is false by default. If set to true, it allows merging two regions from different tables. This option is only effective when the key type is “table”.

TiKV parameters:

  • split-region-on-table, default value is true, which enables splitting Regions by table. To facilitate merging empty regions, this should be set to false.
| username: wakaka | Original post link

I see all the parameters are correct.

| username: Jellybean | Original post link

Does the cluster have tasks that periodically delete large amounts of data? We have tasks that regularly delete large amounts of data every day, and we have a similar situation where the number of empty regions decreases daily, then increases again after deleting large amounts of data, showing a fluctuation that matches our expectations.

| username: wuxiangdong | Original post link

schedule.enable-cross-table-merge
coprocessor.split-region-on-table false

Try reducing the schedule.split-merge-interval time (the default is to merge once every 2 hours).

| username: h5n1 | Original post link

Is there TiFlash? Check with pd-ctl scheduler show.

| username: wakaka | Original post link

Yes, there is TiFlash.

| username: wakaka | Original post link

There are a large number of truncates, but currently there is no fluctuation. These empty regions just do not merge.

| username: wakaka | Original post link

It’s one hour.

| username: h5n1 | Original post link

Check if the PD has a region merge checker panel.

| username: wakaka | Original post link

Yes, but empty still doesn’t merge.

| username: h5n1 | Original post link

Find two adjacent empty regions, where the end key of the first region is the same as the start key of the second region. Manually initiate a merge using pd-ctl operator add merge-region 1 2, then observe the PD leader logs and TiKV logs to check the merge status.

| username: hey-hoho | Original post link

Try adjusting the max-merge-region-keys and max-merge-region-size to be smaller, set the split-merge-interval to 1 minute, and moderately increase the store limit.

| username: wakaka | Original post link

After the merge, one TiFlash node crashed and couldn’t start, and the number of down peers increased.


image

| username: wakaka | Original post link

Isn’t this value supposed to prevent merging if it’s greater? If it’s reduced, wouldn’t it prevent merging even more?

| username: h5n1 | Original post link

Not all tables are synchronized on TiFlash, right?

| username: wakaka | Original post link

No, it’s partial table synchronization. I’m not sure if the empty regions are related to TiFlash. After operating the operator to add merge-region with two region IDs, TiFlash crashed.

| username: h5n1 | Original post link

Please upload the TiFlash error logs, and wait for the TiFlash expert to take a look.

| username: wakaka | Original post link

Link: 百度网盘-链接不存在 Extraction code: 73ix
The log is quite large. The operation started at 09:38 with the operator add merge-region for two region IDs.