Delete Region

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

Original topic: 删除region

| username: 胡杨树旁

[TiDB Usage Environment] Production Environment / Testing / PoC
[TiDB Version]
[Reproduction Path] What operations were performed when the issue occurred
[Encountered Issue: Issue Phenomenon and Impact]
[Resource Configuration]
[Attachments: Screenshots / Logs / Monitoring]
select * from INFORMATION_SCHEMA.TIKV_REGION_STATUS trs Query found that there is a region with table_id and db_id as null


I would like to ask under what circumstances this null situation is formed, and if I want to delete the corresponding region, how should I proceed?

| username: xfworld | Original post link

There’s no need to delete regions. If there are empty regions, the system will automatically merge or clean them up.

| username: 胡杨树旁 | Original post link

I checked the current size of this region, which is 35M, but the parameter is set to 20. Should I modify the parameter?

| username: 大飞哥online | Original post link

Was there a large amount of data deletion before, resulting in many small regions? The system will automatically perform Region Merge after version 3.0.

| username: xfworld | Original post link

If there are no special requirements for the region parameters, don’t adjust them…
The default parameters provided are generally the result of many tests and can adapt to most scenarios.

| username: 大飞哥online | Original post link

Then you can change it to greater than 35M, and after merging, change it back to the default 20M :grinning:

| username: 胡杨树旁 | Original post link

But the monitoring panel does not show any empty regions.

| username: 胡杨树旁 | Original post link

I’ll give it a try to see if it works. If it does, the query “select * from INFORMATION_SCHEMA.TIKV_REGION_STATUS trs” should not display null values, right?

| username: 胡杨树旁 | Original post link

The monitoring shows that there are no empty regions, which feels quite strange.

| username: xfworld | Original post link

That is normal. The range of a region is divided by Key_start and Key_end. If there is no value, it represents infinitely small or infinitely large. This allows data outside the divided range to be accommodated.

| username: 胡杨树旁 | Original post link

After the modification, the query indeed shows that this region no longer exists.

| username: 胡杨树旁 | Original post link

My region doesn’t have a start_key.

| username: 大飞哥online | Original post link

In simple terms, it’s extremely small. If you say there’s nothing, there’s still a tiny bit inside, haha. After merging, remember to change it back to 20M, and it’ll be fine.

| username: 胡杨树旁 | Original post link

Indeed, saying there is none is a bit off, but saying there is some isn’t much either. It has already been reverted.

| username: coderv | Original post link

I encountered the same issue, thanks to the experts.

| username: redgame | Original post link

Use the command tikv-ctl pd destroy-region {region_id} to destroy the corresponding region based on the region ID.

| username: h5n1 | Original post link

Where did you see this command?