Skip to content

Checks for the region label id should be more robust #33665

@CharlesCheung96

Description

@CharlesCheung96

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

➜  curl -X POST http://127.0.0.1:2379/pd/api/v1/config/region-label/rule -H "Content-Type: application/json" --data-binary @- <<DATA
{ "id": "tidb/meta/basic",
   "labels": [{"key": "data-type", "value": "meta"}],
   "rule_type": "key-range",
    "data": [{
         "start_key": "6d00000000000000f8",
         "end_key": "6e00000000000000f8"
   }]
}
DATA

➜  curl -X POST http://127.0.0.1:2379/pd/api/v1/config/region-label/rule -H "Content-Type: application/json" --data-binary @- <<DATA
{ "id": "tidb/meta",
   "labels": [{"key": "data-type", "value": "meta"}],
   "rule_type": "key-range",
    "data": [{
         "start_key": "6d00000000000000f8",
         "end_key": "6e00000000000000f8"
   }]
}
DATA

Run the following command from the mysql client:

select * from information_schema.attributes;
ERROR 1105 (HY000): invalid label rule ID: tidb/meta
ERROR:

2. What did you expect to see? (Required)

+-----------------+-----------+------------------+------------------------------------------+
| ID              | TYPE      | ATTRIBUTES       | RANGES                                   |
+-----------------+-----------+------------------+------------------------------------------+
| tidb/meta/basic | key-range | "data-type=meta" | [6d00000000000000f8, 6e00000000000000f8] |
| tidb/meta       | key-range | "data-type=meta" | [6d00000000000000f8, 6e00000000000000f8] |
+-----------------+-----------+------------------+------------------------------------------+

or something like

+-----------------+-----------+------------------+------------------------------------------+
| ID              | TYPE      | ATTRIBUTES       | RANGES                                   |
+-----------------+-----------+------------------+------------------------------------------+
| tidb/meta/basic | key-range | "data-type=meta" | [6d00000000000000f8, 6e00000000000000f8] |
+-----------------+-----------+------------------+------------------------------------------+
WARNING: invalid label rule ID: tidb/meta

3. What did you see instead (Required)

ERROR 1105 (HY000): invalid label rule ID: tidb/meta
ERROR:

4. What is your TiDB version? (Required)

Release Version: v5.4.0
Edition: Community
Git Commit Hash: 55f3b24c1c9f506bd652ef1d162283541e428872
Git Branch: heads/refs/tags/v5.4.0
UTC Build Time: 2022-01-25 08:41:03
GoVersion: go1.16.4
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions