-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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: Schedule TTL job when ttl_expiration_expression is set after table creation #88260
Conversation
|
||
subtest end | ||
|
||
subtest create_table_no_ttl_set_ttl_expire_after |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved the existing test to a subtest so I can run it individually.
|
||
query TTT | ||
SELECT schedule_status, recurrence, owner FROM [SHOW SCHEDULES] | ||
WHERE label = 'row-level-ttl-$table_id' | ||
---- | ||
ACTIVE @hourly root | ||
|
||
subtest end | ||
|
||
subtest create_table_no_ttl_set_ttl_expiration_expression |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as the existing test but uses ttl_expiration_expression
instead of ttl_expire_after
.
SELECT schedule_status, recurrence, owner FROM [SHOW SCHEDULES] | ||
WHERE label = 'row-level-ttl-$table_id' | ||
---- | ||
ACTIVE @hourly root |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This query returns 0 results without the alter_table.go
change.
going to defer to schema to take a look at this one! |
couple of notes in my head
|
Can we simplify the process and make |
as long as cancelling the job adding or dropping the TTL column also correctly accounts for the schedule creation |
Can The previous |
My problem, from looking at this, is that I don't have a well-formed mental model on how this stuff is supposed to work. @otan I guess I wonder why you think a mutation is in any way wrong here? It seems somewhat important to me. Consider: CREATE TABLE t (
id INT PRIMARY KEY,
text STRING
expire_at TIMESTAMPTZ,
FAMILY (id, text, expire_at)
);
INSERT INTO t VALUES (1, 'a', NULL), (2, 'a', NULL);
BEGIN;
CREATE UNIQUE INDEX idx ON t(text);
ALTER TABLE create_table_no_ttl_set_ttl_expiration_expression SET (ttl_expiration_expression = 'expire_at');
COMMIT; What should happen? I sincerely hope we'd roll back the ttl change. |
ah i think the code as is immediately sets i am totally rusty after 6 months 😬 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's an edge case but what happens if you have multiple ALTER TABLE
commands which muck with row-level TTL settings in the same transaction? My reading is that it's just going to add more mutations. Is that the right thing?
Generally this seems sane to me. Thanks for tracking it down and picking up all the context you did on this code.
statement error "ttl_expire_after" and/or "ttl_expiration_expression" must be set | ||
CREATE TABLE tbl (id INT PRIMARY KEY, text TEXT) WITH (ttl = 'on') | ||
|
||
subtest end | ||
|
||
subtest todo_add_subtests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this about?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was isolating the failing tests to debug by putting them in subtests, but I didn't do all of them so I just moved subtest todo_add_subtests
from above.
pkg/sql/alter_table.go
Outdated
@@ -1847,7 +1844,7 @@ func dropColumnImpl( | |||
|
|||
func handleTTLStorageParamChange( | |||
params runParams, tn *tree.TableName, tableDesc *tabledesc.Mutable, after *catpb.RowLevelTTL, | |||
) error { | |||
) (bool, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: name the return bool
Right now it adds mutations if the job is scheduled/unscheduled and if the column is added/dropped, otherwise it does the change immediately. I have another followup PR to add tests for the immediate vs mutation changes and I can add tests for this also. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
bors r=ajwerner |
Build succeeded: |
fixes #88254
refs #88560
Previously a TTL mutation was added for the schema changer only when
ttl_expire_after was set. Now a TTL mutation is also added when
ttl_expiration_expression is set.
Release note: None