I created the Placement Rules but failed to create the table

Note that this question was originally posted on the Chinese TiDB Forum. We copied it here to help new users solve their problems quickly.

Application environment:

Test environment

TiDB version:

Cluster name: tidb_cluster_v6.0 Cluster version: TiDB v6.0.0

Reproduction method:

I deployed a TiDB cluster using TiUP Cluster

tiup cluster deploy tidb_cluster_v6.0 v6.0.0 /home/tidb/.tiup/storage/cluster/topology.yaml --ssh system

Then I created Placement Rules

CREATE PLACEMENT POLICY 'ke_policy' PRIMARY_REGION=“zeus” REGIONS=“zeus,mars,atlas” FOLLOWERS=4;

Problem:

I created the Placement Rules but failed to create the table. The log is as follows:

11:18 10.200.118.177:4000[Writable] (ke) > CREATE PLACEMENT POLICY 'ke_policy' PRIMARY_REGION=“zeus” REGIONS=“zeus,mars,atlas” FOLLOWERS=4;
Query OK, 0 rows affected (0.08 sec)
11:18 10.200.118.177:4000[Writable] (ke) > create table t1 (id int) PLACEMENT POLICY 'ke_policy' ;
ERROR 8243 (HY000): “[PD:placement:ErrRuleContent]invalid rule content, rule ‘table_rule_74_0’ from rule group ‘TiDB_DDL_74’ can not match any store”
11:19 10.200.118.177:4000[Writable] (ke) > create table t1 (id int);
Query OK, 0 rows affected (0.09 sec)
11:36 10.200.118.177:4000[Writable] (ke) > create table t2 (id int) PLACEMENT POLICY 'ke_policy' ;
ERROR 8243 (HY000): “[PD:placement:ErrRuleContent]invalid rule content, rule ‘table_rule_78_0’ from rule group ‘TiDB_DDL_78’ can not match any store”
11:40 10.200.118.177:4000[Writable] (ke) > show CREATE PLACEMENT POLICY 'ke_policy';
±----------±------------------------------------------------------------------------------------------------+
| Policy | Create Policy |
±----------±------------------------------------------------------------------------------------------------+
| ke_policy | CREATE PLACEMENT POLICY 'ke_policy' PRIMARY_REGION=“zeus” REGIONS=“zeus,mars,atlas” FOLLOWERS=4 |
±----------±------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
11:40 10.200.118.177:4000[Writable] (ke) > alter table t1 PLACEMENT POLICY 'ke_policy' ;
ERROR 8243 (HY000): “[PD:placement:ErrRuleContent]invalid rule content, rule ‘table_rule_76_0’ from rule group ‘TiDB_DDL_76’ can not match any store”
policy ke_policy  LEADER_CONSTRAINTS="[+host=zeus]" FOLLOWER_CONSTRAINTS='{"+host=mars":1,"+host=atlas":1}';

The default PLACEMENT POLICY requires region as a distinguishing label. So when you create a TiKV, you need to explicitly specify the region label of the TiKV. Otherwise, you will not see the region label in the show placement labels.

Thanks, I got it! If you want fine-grained control, you need to label the region. But I don’t know how to label the region. Can you give an example?

You can refer to the parameter specification here: Tune TiKV Memory Parameter Performance | PingCAP Docs