Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better handle invalid rules (error messages from PD) #30415

Open
Tracked by #18030
morgo opened this issue Dec 6, 2021 · 1 comment
Open
Tracked by #18030

Better handle invalid rules (error messages from PD) #30415

morgo opened this issue Dec 6, 2021 · 1 comment
Assignees

Comments

@morgo
Copy link
Contributor

morgo commented Dec 6, 2021

Consider the following scenario:

tidb> show placement labels;
+--------+----------------+
| Key    | Values         |
+--------+----------------+
| disk   | ["ssd"]        |
| region | ["us-east-1"]  |
| zone   | ["us-east-1a"] |
+--------+----------------+
3 rows in set (0.00 sec)

tidb> CREATE PLACEMENT POLICY p1 PRIMARY_REGION="us-east-1" REGIONS="us-east-1,us-east-2";
Query OK, 0 rows affected (0.08 sec)

tidb> CREATE TABLE t1 (a int) PLACEMENT POLICY=p1;
ERROR 1105 (HY000): failed to notify PD the placement rules: "[PD:placement:ErrRuleContent]invalid rule content, rule 'table_rule_58_1' from rule group 'TiDB_DDL_58' can not match any store"

The syntax is correct, but the rule fails because the region does not exist. I propose the following fixes:

  1. We validate PRIMARY_REGION and REGIONS upon creating the placement policy p1 against the list of known values. This won't protect against a race condition that the region could become unavailable in between the policy being created and the table created, so an error could still be returned by PD.

  2. If an error is returned by PD, can we make this easier to understand? Something like "'table_rule_58_1' from rule group 'TiDB_DDL_58' can not match any store. Check to make sure that all stores are online, and the constraints you are specifying are able to be set".

  3. Can we expose DDL_58 in information_schema.placement_rules? A user might be logging these errors and it should be possible to match internal IDs like this, since we can currently map tables to table IDs.

@sylzd
Copy link
Contributor

sylzd commented Dec 17, 2021

/assign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants