merge-checker: The empty region corresponding to the dropped table cannot be merged forever with `enable-cross-table-merge` false
- Dominant language
- Go
- Stars
- 1.2k
- Forks
- 783
- Avg merge
- 5d 21h
- Merged PRs (30d)
- 36
Description
## Bug Report
The empty region corresponding to the dropped table cannot be merged forever with `enable-cross-table-merge` false.
### What did you do?
First, I adjusted the following configuration, expecting each region to contain data for only one table.
```
tiup ctl:v7.5.2 pd config set enable-cross-table-merge false
Starting component ctl: /home/tidb/.tiup/components/ctl/v7.5.2/ctl pd config set enable-cross-table-merge false
Success!
mysql> set config tikv `coprocessor.split-region-on-table`=true;
Query OK, 0 rows affected (0.01 sec)
```
2.create a new database and create 100 tables in it: After creating 100 tables, I saw that 300 new regions were created.
```
sysbench --config-file=config oltp_point_select --tables=100 --table-size=10 prepare
mysql> select count(*),DB_name from information_schema.TIKV_REGION_STATUS where DB_name='crosstable'\G
*************************** 1. row ***************************
count(*): 400
DB_name: crosstable
select distinct(region_id) from information_schema.TIKV_REGION_STATUS where DB_name='crosstable'\G
...
region_id: 539796156
*************************** 297. row ***************************
region_id: 539795040
*************************** 298. row ***************************
region_id: 539794808
*************************** 299. row ***************************
region_id: 539794792
*************************** 300. row ***************************
region_id: 539794976
300 rows in set (0.09 sec)
```
3. drop databse:Just delete all these one hundred tables directly.
```
mysql> drop database crosstable;
Query OK, 0 rows affected (2.02 sec)
```
### What did you expect to see?
The number of empty regions will be restored to the state before testing began, which means that the regions corresponding to these 100 tables should be merged together.
### What did you see instead?
The number of empty regions increased by 100 compared to before the test, meaning that each of these one hundred tables left behind an empty region.

The reason for the inability to merge is "adj-disallow-merge"

It returns false on L292
https://github.com/tikv/pd/blob/358de1047cd2053e065d059f877cdb86e8645b13/pkg/schedule/checker/merge_checker.go#L282-L298
The main reason is that PD cannot know if the region corresponding to the table has been completely deleted(drop). PD needs a method to distinguish between drop table and truncate table's empty regions in order to fix this issue.
### What version of PD are you using (`pd-server -V`)?
v7.5.2
Contributor guide
Assessment
This issue has not been assessed yet.