tikv / pd

Placement driver for TiKV

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rules: show rules by region does not print all matched rules

AndreMouche opened this issue · comments

Bug Report

What did you do?

step1: show default placment-rule config

tiup ctl:v6.5.0 pd config placement-rules show
Starting component ctl: /home/tidb/.tiup/components/ctl/v6.5.0/ctl pd config placement-rules show
  {
    "group_id": "pd",
    "id": "default",
    "start_key": "",
    "end_key": "",
    "role": "voter",
    "is_witness": false,
    "count": 5,
    "version": 1
  }
]

add new placement rule for table customer:

mysql> create placement policy 3replias FOLLOWERS=2;
Query OK, 0 rows affected (0.11 sec)

mysql> alter table customer placement policy=3replias;
Query OK, 0 rows affected (0.17 sec)

show placementrule for region in customer

tiup ctl:v7.5.0 pd config  placement-rules show --region 2023
Starting component `ctl`: /home/fun/.tiup/components/ctl/v7.5.0/ctl pd config placement-rules show --region 2023
[
  {
    "group_id": "TiDB_DDL_126",
    "id": "partition_rule_127_0",
    "index": 80,
    "start_key": "7480000000000000ff7f00000000000000f8",
    "end_key": "7480000000000000ff8000000000000000f8",
    "role": "voter",
    "is_witness": false,
    "count": 3,
    "label_constraints": [
      {
        "key": "engine",
        "op": "notIn",
        "values": [
          "tiflash"
        ]
      }
    ],
    "create_timestamp": 1718890121
  }
]

show placement rule for region not from customer:

 tiup ctl:v7.5.0 pd config  placement-rules show --region 36  
Starting component `ctl`: /home/fun/.tiup/components/ctl/v7.5.0/ctl pd config placement-rules show --region 36
[
  {
    "group_id": "pd",
    "id": "default",
    "start_key": "",
    "end_key": "",
    "role": "voter",
    "is_witness": false,
    "count": 5,
    "version": 1
  }
]


What did you expect to see?

according the description of https://docs.pingcap.com/tidb/stable/configure-placement-rules ,

To view the rule list that matches a Region:
pd-ctl config placement-rules show --region=2
In the above example, 2 is the Region ID.

show placementrule for region in customer should return 2 rules:

tiup ctl:v7.5.0 pd config  placement-rules show --region 2023
Starting component `ctl`: /home/fun/.tiup/components/ctl/v7.5.0/ctl pd config placement-rules show --region 2023
[  {
    "group_id": "TiDB_DDL_126",
    "id": "partition_rule_127_0",
    "index": 80,
    "start_key": "7480000000000000ff7f00000000000000f8",
    "end_key": "7480000000000000ff8000000000000000f8",
    "role": "voter",
    "is_witness": false,
    "count": 3,
    "label_constraints": [
      {
        "key": "engine",
        "op": "notIn",
        "values": [
          "tiflash"
        ]
      }
    ],
    "create_timestamp": 1718890121
  },
  {
      "group_id": "pd",
      "id": "default",
      "start_key": "",
      "end_key": "",
      "role": "voter",
      "is_witness": false,
      "count": 5,
      "version": 1
   }
]

What did you see instead?

tiup ctl:v7.5.0 pd config  placement-rules show --region 2023
Starting component `ctl`: /home/fun/.tiup/components/ctl/v7.5.0/ctl pd config placement-rules show --region 2023
[
  {
    "group_id": "TiDB_DDL_126",
    "id": "partition_rule_127_0",
    "index": 80,
    "start_key": "7480000000000000ff7f00000000000000f8",
    "end_key": "7480000000000000ff8000000000000000f8",
    "role": "voter",
    "is_witness": false,
    "count": 3,
    "label_constraints": [
      {
        "key": "engine",
        "op": "notIn",
        "values": [
          "tiflash"
        ]
      }
    ],
    "create_timestamp": 1718890121
  }
]

What version of PD are you using (pd-server -V)?

master

The current behavior is as expected.