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

release-2.1: table caching and zone config improvements #30173

Merged
merged 14 commits into from Sep 13, 2018

Conversation

benesch
Copy link
Contributor

@benesch benesch commented Sep 13, 2018

Backport:

Please see individual PRs for details. Grouping these mostly unrelated PRs together avoids a merge conflict in pkg/sql/set_zone_config.go.

/cc @cockroachdb/release

Fix #30045.

vivekmenezes and others added 14 commits September 12, 2018 22:23
This helper function resolves and returns a mutable table descriptor
from the store.

Release note: None
This helper returns an uncached database descriptor
that can be used by a schema change. Schema changes
on tables and other schema elements always read the
database from the store even when the database itself
is not going to change. Use this for an immutable
database.

Release note: None
It helps resolve an uncached immutable table descriptor
needed in various SHOW commands.

Release note: None
writeSchemaChange() already calls ValidateTable() within
writeTableDescToBatch().

Release note: None
change the implementation to always return an uncached database
descriptor from the store.

Release note: None
the new method also resolves the index name by going to the
store. It also returns a MutableTableDescriptor.

Release note: None
This is part 1/3 of the general project to improve the UX of zone
configurations in CockroachDB 2.1.

This patch does the following:

- it removes the EXPERIMENTAL keyword from the grammar for statements
  that view or change zone configurations.
- it adds missing SQL contextual help strings.
- it removes the "skip doc" parser annotation so that syntax diagrams
  can be generated.
- it modifies the `cockroach zone` CLI utility to avoid using
  the EXPERIMENTAL keyword. For compatibility with pre-2.1 nodes,
  the code falls back to using EXPERIMENTAL if the syntax without
  EXPERIMENTAL is not recognized.

Release note (cli change): `cockroach zone rm` will now produce no
output unless an error occurs.
This is part 2/3 of of the general project to improve the UX of zone
configurations in CockroachDB 2.1.

This patch does the following:

- it creates a new column `config_sql` in `crdb_internal.zones` and
  the output of SHOW ZONE CONFIGURATION. This contains a
  copy of the allowed ALTER syntax which will be introduced in the
  next patch.

- it cleans up and simplifies the implementation ALTER ... CONFIGURE
  ZONE, thereby simplifying further improvements.

This patch also makes ALTER ... CONFIGURE ZONE able to accept strings
that do not contain a terminating newline. This makes it possible to
specify unescaped strings, for example `ALTER ... CONFIGURE ZONE
'num_replicas: 3'` where previously one would have needed to specify
`e'num_replicas:3 \n'`.

The behavior for deletion is preserved: a NULL values requests a
removal of the zone configuration; an empty string (or containing only
whitespace) is a no-op (not a deletion).

Release note: None
This is part 3/3 of the general project to improve the UX of zone
configurations in CockroachDB 2.1.

This patch introduces the extended syntax for the ALTER ... CONFIGURE
ZONE statement. The following forms are now supported:

```
-- New: remove a zone configuration.
ALTER ... CONFIGURE ZONE DISCARD;

-- New: reset a zone config to the inherited defaults.
ALTER ... CONFIGURE ZONE USING DEFAULT;

-- New: configure parameters using SQL expressions.
-- Setting `constraints` and `lease_preferences` still uses YAML.
ALTER ... CONFIGURE ZONE USING
    num_replicas = 1, gc.ttlseconds = 3600,
    constraints = '[+attr=ssd]';

-- Preserved for backward compatibility:
-- set multiple variables at once using YAML.
ALTER ... CONFIGURE ZONE = '...yaml...';

-- Preserved for backward compatibility;
-- equivalent to ALTER ... CONFIGURE ZONE DISCARD:
ALTER ... CONFIGURE ZONE = NULL;
```

The disambiguation using either `=` (or, equivalently, TO) or USING is
necessary to disambiguate the grammar (`ZONE foo = bar` would be
parsable as either the first form with expression `(foo = bar)` or the
second form with a single parameter set).

Additionally, this patch ensures (and tests) that the ALTER
... CONFIGURE ZONE statements can be prepared and use placeholders.

Release note (sql change): CockroachDB now recognizes `ALTER
... CONFIGURE ZONE` to add, modify, reset and remove zone
configurations.

Release note (sql change): The SQL statements to modify zone
configurations can now use placeholders (`$1`, etc) and be prepared
for multiple executions.
Requested/suggested by @benesch: this patch makes the various
`cockroach zone` sub-commands report a deprecation warning and a
reference to the new SQL interface:

```
$ cockroach zone ls
Command "ls" is deprecated, use SHOW ZONE CONFIGURATIONS in a SQL client instead.

$ cockroach zone get .default
Command "get" is deprecated, use SHOW ZONE CONFIGURATION FOR ... in a SQL client instead.

$ cockroach zone set .default
Command "set" is deprecated, use ALTER ... CONFIGURE ZONE in a SQL client instead.

$ cockroach zone rm liveness
Command "rm" is deprecated, use ALTER ... CONFIGURE ZONE DISCARD in a SQL client instead.
```

Release note (cli change): The various `cockroach zone` sub-commands
are now deprecated and will be removed in a future version of
CockroachDB. Clients should use the SQL interface instead via `SHOW
ZONE CONFIGURATION(s)` or `ALTER ... CONFIGURE ZONE`.
@benesch benesch requested a review from a team as a code owner September 13, 2018 02:26
@benesch benesch requested review from a team September 13, 2018 02:26
@benesch benesch requested a review from a team as a code owner September 13, 2018 02:26
@benesch benesch requested review from a team September 13, 2018 02:26
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@vivekmenezes vivekmenezes merged commit 544c6e4 into cockroachdb:release-2.1 Sep 13, 2018
@knz
Copy link
Contributor

knz commented Sep 13, 2018

LGTM but I am getting the impression the review process didn't go as intended?

@vivekmenezes
Copy link
Contributor

I reviewed it and hit the merge button. I suppose we're not used to that, but why not on these release branches.

@benesch
Copy link
Contributor Author

benesch commented Sep 13, 2018

Definitely OK to use the big green button on these release branches! (Announcements have been made to that effect on #engineering.) I think @knz may have been expecting to review the backport of his commits before the PR merged—but no harm done, since it looked good to everyone!

@knz
Copy link
Contributor

knz commented Sep 13, 2018

Oh no I was OOO so wasn't expecting to review. I was simply surprised, it's not often that the reviewer is also the person who merges.

@benesch
Copy link
Contributor Author

benesch commented Sep 13, 2018

Oh, I see. In this case I opened the PR at Vivek's request so it wasn't really my PR. :)

@knz
Copy link
Contributor

knz commented Sep 13, 2018

All good 👍

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

Successfully merging this pull request may close these issues.

None yet

4 participants