cockroachdb / cockroachdb/cockroach

Enforce strict syntax for replication zone configurations

Open
#124,520 0 comments 0 reactions 0 assignees View on GitHub
A-cli-client A-cluster-observability A-sql-cli-observability A-sql-observability C-enhancement T-observability
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

**Is your feature request related to a problem? Please describe.**

Customer made a typo and parser/cli did not notify the customer, causing them to believe the replication zone was correctly configured while in reality it was not.

**Describe the solution you'd like**

Customer would like to have strict enforcement of semantics and syntax for replication zone configurations. Customer would also like the parser to error out if the syntax is incorrect for replication zone configurations.

**Describe alternatives you've considered**

Not applicable

**Additional context**

Full scenario showing the differences when customer made a typo / used wrong syntax:

```
admin@crdbserver:443/defaultdb> create table test(id int);
CREATE TABLE

Time: 100ms total (execution 28ms / network 72ms)
```

The following caused the incorrect `lease_preference` although no error was thrown:

```
lease_preferences = '[[+region=us-east-2]], [[+region=us-east-1]], [[-region=us-west-2]]]';
```

and this is the correct syntax:

```
lease_preferences = '[[+region=us-east-2], [+region=us-east-1], [-region=us-west-2]]';
```

Full examples below

Bad Syntax

```
admin@crdbserver:443/defaultdb> ALTER TABLE test CONFIGURE ZONE USING
range_min_bytes = 134217728,
range_max_bytes = 536870912,
gc.ttlseconds = 90000,
num_replicas = 5,
num_voters = 5,
constraints = '{+region=us-east-1: 2, +region=us-east-2: 2, +region=us-west-2: 1}',
voter_constraints = '{+region=us-east-2: 2}',
lease_preferences = '[[+region=us-east-2]], [[+region=us-east-1]], [[-region=us-west-2]]]';
CONFIGURE ZONE 1

Time: 100ms total (execution 27ms / network 73ms)
```

```
admin@crdbserver:443/defaultdb> show create table test;
table_name | create_statement
-------------+------------------------------------------------------------------------------------------
test | CREATE TABLE public.test (
| id INT8 NULL,
| rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(),
| CONSTRAINT test_pkey PRIMARY KEY (rowid ASC)
| );
| ALTER TABLE defaultdb.public.test CONFIGURE ZONE USING
| range_min_bytes = 134217728,
| range_max_bytes = 536870912,
| gc.ttlseconds = 90000,
| num_replicas = 5,
| num_voters = 5,
| constraints = '{+region=us-east-1: 2, +region=us-east-2: 2, +region=us-west-2: 1}',
| voter_constraints = '{+region=us-east-2: 2}',
| lease_preferences = '[[+region=us-east-2]]'
(1 row)

Time: 120ms total (execution 49ms / network 71ms)
```

```
admin@crdbserver:443/defaultdb> ALTER TABLE test CONFIGURE ZONE USING
range_min_bytes = 134217728,
range_max_bytes = 536870912,
gc.ttlseconds = 90000,
num_replicas = 5,
num_voters = 5,
constraints = '{+region=us-east-1: 2, +region=us-east-2: 2, +region=us-west-2: 1}',
voter_constraints = '{+region=us-east-2: 5}',
lease_preferences = '[[+region=us-east-2]], [[+region=us-east-1]], [[-region=us-west-2]]]';
CONFIGURE ZONE 1

Time: 99ms total (execution 27ms / network 72ms)
```

```
admin@crdbserver:443/defaultdb> show create table test;
table_name | create_statement
-------------+------------------------------------------------------------------------------------------
test | CREATE TABLE public.test (
| id INT8 NULL,
| rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(),
| CONSTRAINT test_pkey PRIMARY KEY (rowid ASC)
| );
| ALTER TABLE defaultdb.public.test CONFIGURE ZONE USING
| range_min_bytes = 134217728,
| range_max_bytes = 536870912,
| gc.ttlseconds = 90000,
| num_replicas = 5,
| num_voters = 5,
| constraints = '{+region=us-east-1: 2, +region=us-east-2: 2, +region=us-west-2: 1}',
| voter_constraints = '{+region=us-east-2: 5}',
| lease_preferences = '[[+region=us-east-2]]'
(1 row)

Time: 119ms total (execution 46ms / network 74ms)
```

Good Syntax

```
admin@crdbserver:443/defaultdb> ALTER TABLE test CONFIGURE ZONE USING
range_min_bytes = 134217728,
range_max_bytes = 536870912,
gc.ttlseconds = 90000,
num_replicas = 5,
num_voters = 5,
constraints = '{+region=us-east-1: 2, +region=us-east-2: 2, +region=us-west-2: 1}',
voter_constraints = '{+region=us-east-2: 2}',
lease_preferences = '[[+region=us-east-2], [+region=us-east-1], [-region=us-west-2]]';
CONFIGURE ZONE 1

Time: 99ms total (execution 28ms / network 71ms)
```

```
admin@crdbserver:443/defaultdb> show create table test;
table_name | create_statement
-------------+--------------------------------------------------------------------------------------------
test | CREATE TABLE public.test (
| id INT8 NULL,
| rowid INT8 NOT VISIBLE NOT NULL DEFAULT unique_rowid(),
| CONSTRAINT test_pkey PRIMARY KEY (rowid ASC)
| );
| ALTER TABLE defaultdb.public.test CONFIGURE ZONE USING
| range_min_bytes = 134217728,
| range_max_bytes = 536870912,
| gc.ttlseconds = 90000,
| num_replicas = 5,
| num_voters = 5,
| constraints = '{+region=us-east-1: 2, +region=us-east-2: 2, +region=us-west-2: 1}',
| voter_constraints = '{+region=us-east-2: 2}',
| lease_preferences = '[[+region=us-east-2], [+region=us-east-1], [-region=us-west-2]]'
(1 row)

Time: 116ms total (execution 46ms / network 71ms)
```

Jira issue: CRDB-38941

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.