ALTER RANGE meta generates confusing key range that overlaps RawKV prefix
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
When using ALTER RANGE meta in TiDB to assign placement rules to the meta key range, the generated end key is currently set to the table prefix (tablePrefix), as seen [here](https://github.com/pingcap/tidb/blob/d48ac38676f9569112cd881edbc700fedd675b7d/pkg/ddl/placement/bundle.go#L466).
However, there is a RawKV prefix ('r', 0x72) that falls between the meta key range end and the table key range start. This means the generated placement rule technically covers both:
Meta key ranges (intended target) ✅
Raw key ranges ('r' prefix) ❌ (not expected for most TiDB users)
Most TiDB customers never use the RawKV interface, so this overlap usually has no practical effect. Still, the current behavior is confusing and misleading because:
The placement rules suggest RawKV keys are part of the meta range.
It creates unnecessary ambiguity when reasoning about region placement.
For users who do use RawKV, this could lead to unexpected replica placement policies being applied.
### 1. Minimal reproduce step (Required)
* Create a placement policy for meta regions:
`CREATE PLACEMENT POLICY `meta_policy` FOLLOWERS=4;`
* Assign the policy to the meta key range:
`ALTER RANGE META PLACEMENT POLICY = 'meta_policy';`
* Check the generated placement rules in PD
* Observe that the end key of the meta range is set to the table prefix (t, 0x74).
* Note that the RawKV prefix (r, 0x72) falls between the meta prefix (m, 0x6d) and the table prefix.
### 2. What did you expect to see? (Required)
The placement rule for the meta range should exclude the RawKV keyspace (r, 0x72) and only cover the actual meta range.
That is, the key range should be:
`[metaPrefix ('m'), rawPrefix ('r'))`
instead of:
`[metaPrefix ('m'), tablePrefix ('t'))`
### 3. What did you see instead (Required)
The placement rule currently sets the end key to the table prefix (t, 0x74), which includes the RawKV keyspace (r, 0x72`) in the range.
This is confusing because it suggests RawKV keys are part of the meta range, even though most TiDB users do not use RawKV.
For users who do use RawKV, it may cause unintended placement of raw keys.
### 4. What is your TiDB version? (Required)
v7.5 & v8.5
Contributor guide
Assessment
This issue has not been assessed yet.