Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: 空region为什么没自动合并

Why didn’t the empty region merge automatically?
Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: 空region为什么没自动合并
Why didn’t the empty region merge automatically?
If it hasn’t exceeded the split-merge-interval, it won’t merge. Check your configuration for this. Also, check max-merge-region-size, max-merge-region-keys, and merge-schedule-limit. See if they are all normal. Additionally, if enable-cross-table-merge is set to false, an empty table will result in an empty region, which also won’t merge.
All are default values, not adjusted.
schedule.split-merge-interval is 1h0m0s
schedule.max-merge-region-size is 20
schedule.max-merge-region-keys is 200000
schedule.enable-cross-table-merge is true
So, have the merge conditions not been triggered yet?
This situation has been going on for a long time; it’s not a matter of time.
The conditions for merging have not been met yet, right?
Query and check
SELECT
store_id,
leader_count,
region_count
FROM
INFORMATION_SCHEMA.TIKV_STORE_STATUS;
The image cannot be translated directly. Please provide the text content for translation.
The reason we encountered many empty regions before was that the task to merge regions failed. After expanding the PD memory, it returned to normal.
±---------±-------------±-------------+
| store_id | leader_count | region_count |
±---------±-------------±-------------+
| 4 | 185 | 544 |
| 5 | 177 | 544 |
| 1 | 182 | 544 |
±---------±-------------±-------------+
You can check the log on the PD leader node and use “empty region” as the keyword to confirm if there are any related scheduling policies running.
After creating a large number of tables (including executing the Truncate Table operation) and then clearing them, if the split table feature is enabled, these empty Regions cannot be merged. At this point, you need to adjust the following parameters to disable this feature:
TiKV: Set split-region-on-table to false. This parameter does not support dynamic modification.
If there are not more than 10,000 empty regions, it is probably not a configuration issue. It is very likely that there are some partition tables based on time. Each partition actually corresponds to a physical table with its own table_id. If the time has not arrived, this physical table is empty, and the corresponding region is also an empty region.
It doesn’t look like you have many empty regions, so first consider whether it is the situation mentioned above.
Check the parameter values of region_merge and adjust them as needed. If they are configured properly but not executed, you will need to look at the logs on PD.