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

ttl: finalize for v22.1 release #76918

Merged
merged 6 commits into from
Feb 25, 2022
Merged

Conversation

otan
Copy link
Contributor

@otan otan commented Feb 23, 2022

See individual commits for details.

Big release note on the last commit.

@otan otan requested review from rafiss and a team February 23, 2022 05:54
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@otan otan mentioned this pull request Feb 23, 2022
30 tasks
@otan otan force-pushed the cleanup branch 2 times, most recently from b2b7b2c to a95d147 Compare February 23, 2022 06:27
otan added 4 commits February 23, 2022 20:19
Supporting descending order PKs is complex as it requires a more
complicated pagination algorithm. As such, let's not support such a
table for now.

Release note: None
Note we allow this for CREATE TABLE so SHOW CREATE TABLE round trips.
But we should never need this for the ALTER TABLE ... SET ...

Release note: None
@otan otan force-pushed the cleanup branch 3 times, most recently from a0bb13e to 6681c29 Compare February 23, 2022 09:45
Copy link
Collaborator

@rafiss rafiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!!

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @otan and @rafiss)


-- commits, line 40 at r6:
nit: "which is available as a beta feature"


-- commits, line 65 at r6:
nit: maybe mention that the rate is per second?


pkg/sql/catalog/tabledesc/structured.go, line 2527 at r5 (raw file):

// GetStorageParams implements the TableDescriptor interface.
func (desc *wrapper) GetStorageParams(spaceBetweenEqual bool) []string {

i wonder if there's a good way to make sure we don't forget to update this function when new storage params are added

This commit fixes up any post-v22.1 TODOs with unimplemented messages
or comments annotations for the future.

Release note (sql change): We introduce a new row level TTL feature to
CockroachDB, which is available as a beta feature. This allows users to
use a special syntax to automatically mark rows for deletion. Rows are
deleted using a SCHEDULED JOB.

A user can create a table with TTL using:
```
CREATE TABLE t (id INT PRIMARY KEY) WITH (ttl_expire_after = '10 mins')
```

Where `ttl_expire_after` is a duration expression. A user can also add
TTL to an existing table using
```
ALTER TABLE t SET (ttl_expire_after = '10 mins')
```

This creates a new column, `crdb_internal_expiration`, which
automatically is set to `now() + ttl_expire_after` when inserted by
default or on update. The scheduled job will delete any rows which
exceed this timestamp as of the beginning of the job run.

The TTL job is configurable in a few ways using the WITH/SET syntax:
* ttl_select_batch_size: how many rows to select at once (by default
  it is cluster setting sql.ttl.default_select_batch_size)
* ttl_delete_batch_size: how many rows to delete at once (default
  cluster setting sql.ttl.default_select_batch_size)
* ttl_delete_rate_limit: maximum rows to delete per second for
  the given table (default cluster setting
  sql.default.default_delete_rate_limit)
* ttl_pause: pauses the TTL job (also globally pausable with
  `sql.ttl.job.enabled`).

Using `ALTER TABLE table_name RESET (<parameter>)` will reset the
parameter to re-use the default, or `RESET(ttl)` will
disable the TTL job for the table and remove the
`crdb_internal_expiration` column.
Copy link
Contributor Author

@otan otan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @rafiss)


pkg/sql/catalog/tabledesc/structured.go, line 2527 at r5 (raw file):

Previously, rafiss (Rafi Shamim) wrote…

i wonder if there's a good way to make sure we don't forget to update this function when new storage params are added

maybe check all CREATE TABLE in logic test is self reproducing, heh....

@otan
Copy link
Contributor Author

otan commented Feb 25, 2022

bors r=rafiss

@craig
Copy link
Contributor

craig bot commented Feb 25, 2022

This PR was included in a batch that was canceled, it will be automatically retried

@craig
Copy link
Contributor

craig bot commented Feb 25, 2022

Build succeeded:

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.

3 participants