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为什么没自动合并

| username: terry0219

Why didn’t the empty region merge automatically?

| username: TiDBer_jYQINSnf | Original post link

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.

| username: terry0219 | Original post link

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?

| username: 友利奈绪 | Original post link

Need to check the configuration.

| username: DBAER | Original post link

Pull the timeline, has the time point not been reached yet?

| username: terry0219 | Original post link

This situation has been going on for a long time; it’s not a matter of time.

| username: TiDBer_QYr0vohO | Original post link

The conditions for merging have not been met yet, right?

| username: TIDB-Learner | Original post link

Query and check

SELECT
	store_id,
	leader_count,
	region_count 
FROM
	INFORMATION_SCHEMA.TIKV_STORE_STATUS;
| username: TIDB-Learner | Original post link

The image cannot be translated directly. Please provide the text content for translation.

| username: kkpeter | Original post link

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.

| username: terry0219 | Original post link

±---------±-------------±-------------+
| store_id | leader_count | region_count |
±---------±-------------±-------------+
| 4 | 185 | 544 |
| 5 | 177 | 544 |
| 1 | 182 | 544 |
±---------±-------------±-------------+

| username: Jellybean | Original post link

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.

| username: zhh_912 | Original post link

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.

| username: 有猫万事足 | Original post link

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.

| username: zhaokede | Original post link

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.

| username: yytest | Original post link

It should not have triggered the merge.