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

Enforce strict syntax for replication zone configurations #124520

Open
daniel-crlabs opened this issue May 21, 2024 · 0 comments
Open

Enforce strict syntax for replication zone configurations #124520

daniel-crlabs opened this issue May 21, 2024 · 0 comments
Labels
A-cli-client CLI commands that pertain to using SQL features A-cluster-observability Related to cluster observability A-sql-cli-observability Issues related to surfacing SQL observability in SHOW, CRDB_INTERNAL, SYSTEM, etc. A-sql-observability Related to observability of the SQL layer C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-observability

Comments

@daniel-crlabs
Copy link
Contributor

daniel-crlabs commented May 21, 2024

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

@daniel-crlabs daniel-crlabs added C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) A-sql-observability Related to observability of the SQL layer A-cli-client CLI commands that pertain to using SQL features A-sql-cli-observability Issues related to surfacing SQL observability in SHOW, CRDB_INTERNAL, SYSTEM, etc. A-cluster-observability Related to cluster observability T-observability labels May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cli-client CLI commands that pertain to using SQL features A-cluster-observability Related to cluster observability A-sql-cli-observability Issues related to surfacing SQL observability in SHOW, CRDB_INTERNAL, SYSTEM, etc. A-sql-observability Related to observability of the SQL layer C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-observability
Projects
None yet
Development

No branches or pull requests

1 participant