cockroachdb / docs

CockroachDB user documentation
https://cockroachlabs.com/docs
Creative Commons Attribution 4.0 International
187 stars 453 forks source link

Clarify and add examples for zone config constraints with hierarchy #4459

Open jseldess opened 5 years ago

jseldess commented 5 years ago

Jesse Seldess commented:

https://www.cockroachlabs.com/docs/stable/configure-replication-zones.html#types-of-constraints

Question from @robert-s-lee:

ALTER PARTITION user1 OF TABLE defaultdb.usertable CONFIGURE ZONE USING constraints='[+cloud=gce,region=us-east1,zone=us-east1-b]', lease_preferences='[[+cloud=gce,region=us-east1,zone=us-east1-b]]'; ALTER PARTITION user2 OF TABLE defaultdb.usertable CONFIGURE ZONE USING constraints='[+cloud=gce,region=us-west1,zone=us-west1-b]', lease_preferences='[[+cloud=gce,region=us-west1,zone=us-west1-b]]'; ALTER PARTITION user3 OF TABLE defaultdb.usertable CONFIGURE ZONE USING constraints='[+cloud=gce,region=europe-west2,zone=europe-west2-b]', lease_preferences='[[+cloud=gce,region=europe-west2,zone=europe-west2-b]]';
Error: pq: could not validate zone config: constraints must either be required (prefixed with a '+') or prohibited (prefixed with a '-')

Jira Issue: DOC-250

jseldess commented 5 years ago

From https://github.com/cockroachdb/docs/issues/4447:

Currently today the only example of an array I could find on the page is the following: constraints = '[+ssd, -region=west]' I think it would be great to perhaps show something like:

constraints = '[+region=west, +region=central]' to make it clear how this could be used. Showing this in an alter statement down the page would also be great.

rkruze commented 5 years ago

From my understanding, constraints = '[+region=west, +region=central]' doesn't work as it will look for a node with both region set to "west" and also set to "central". Most likely no nodes will fit this constraint. You could have constraints like constraints = '[+cloud=aws, +region=central]'