Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: placement rule 策略会导致region数量成倍增加
[TiDB Usage Environment] Production Environment
[TiDB Version] v6.5.0
[Reproduction Path] After large-scale cleanup of empty partition placement rules, the number of regions and peer count will drop sharply.
[Encountered Problem: Problem Phenomenon and Impact]
[Attachment: Screenshot/Log/Monitoring]
I didn’t understand. You can count the number of regions and peers for each table before, what the placement rule is, and then how much it is after removing it.
Take a look at your placement rule and then compare it with the modified one. The information you provided only shows that the region peer has decreased, and the region has also decreased.
The image is not available for translation. Please provide the text content directly.
Before and after modifying the parameters, you can check the two views, INFORMATION_SCHEMA.TIKV_REGION_STATUS and INFORMATION_SCHEMA.TIKV_REGION_PEERS, and query the region_id to find out the number of regions, size, and number of peers for a specific table. Don’t look at the total amount; compare a specific table instead.
When applying placement rules to existing data, the number of regions is actually unaffected. However, when configuring this strategy for partitions without any data, the number of regions will increase. But from the show table regions
, the APPROXIMATE_SIZE of the newly added regions shows 31MB. It feels like this will occupy disk space, right?
It feels quite strange, I’ll test it later. What is your rule, is it still 1 leader and 2 followers?
Defined a bu and fun tag.
It is 1 leader and 2 followers.
How does this increase the number of regions? I don’t understand.
When setting placement rule rules for tables or partitions using placement rule in SQL, regions will be split according to the boundaries of the placement rule. The corresponding operator type is rule-split-region, which will lead to an increase in the number of regions. This is expected and can be observed through PD logs.
When there is data in the table, this phenomenon is not very obvious because a table involves multiple regions. When the table is empty, one region corresponds to multiple tables. At this time, setting placement rules in SQL will result in many regions being split.
When the table is empty, one region can correspond to multiple tables.
Generally speaking, a newly created table usually has one table per region, right?
At most, one table will have one more region, it won’t be many more.
When creating a new table, each table will have one region, TiDB 配置文件描述 | PingCAP 文档中心
However, it is possible for them to be merged together by PD, PD 配置文件描述 | PingCAP 文档中心
In fact, it is very difficult to trigger this. You can see in INFORMATION_SCHEMA.TIKV_REGION_STATUS that there is one regionid for multiple tables, which are generally system tables.
Yes, because only adjacent regions can be merged, and the prerequisites for merging must be met.
Usually, it rises slowly, even when creating a new ordinary table, it doesn’t spike. However, when the database is configured with a placement rule and a large number of empty partitions are created in a partitioned table, it can easily rise. It’s quite worrisome to watch.