-
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: do not remove all table TTL settings on RESET (ttl_expire_after) #110252
Conversation
descriptorChanged = true | ||
} | ||
if !descriptorChanged { | ||
// Add TTL mutation so that job is scheduled in SchemaChanger. |
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.
super nit: "enqueue TTL mutation ..." might be better since the direction might be add or drop.
case before != nil && after == nil: | ||
direction = descpb.DescriptorMutation_DROP | ||
default: | ||
descriptorChanged = true |
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.
while you are on this, let's improve around descriptorChanged
in the following two ways:
- Rename it to something like
canDirectlyModifyDescriptor
so we know that it's true if we are not enqueuing any mutations and can directly modify the descriptor here; - Return value from this function will be something like
canDirectlyModifyDescriptor || hasEnqueuedAnyMutation
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.
Good work! I have two last questions:
-
If both
ttl_expire_after
andttl_expirataion_expression
are set, and we resetttl_expire_after
, the new code path, as I understand it, will be
1). Enqueue a DropColumn mutation (so we drop "expire_at" column)
2). Don't enqueue a TTL mutation but instead directly modify the TTL field on the descriptor
Correct? -
If we only have
ttl_expire_after
set, and we reset it, it seems to me the same two things above will happen, but maybe later in descriptor validation, we will reject it, right?
1-1) It drops |
Oh, my previous thoughts were wrong. Thanks!
This is somewhat surprising. Are you sure? In this case, This question and two of my unresolved comments are the only things I have. Thanks for doing this! |
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, apart from Xiang's comments
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @chrisseto, @ecwall, and @Xiang-Gu)
This code is confusing because it may also be modified in the |
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.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @chrisseto and @Xiang-Gu)
pkg/sql/alter_table.go
line 1958 at r6 (raw file):
Previously, Xiang-Gu (Xiang Gu) wrote…
while you are on this, let's improve around
descriptorChanged
in the following two ways:
- Rename it to something like
canDirectlyModifyDescriptor
so we know that it's true if we are not enqueuing any mutations and can directly modify the descriptor here;- Return value from this function will be something like
canDirectlyModifyDescriptor || hasEnqueuedAnyMutation
I took this name from descriptorChanged
at the call site. If you want to change this, can you file a separate issue?
The call site documents that descriptorChanged
should be true only if no mutations are added so it should be changed there also.
// Commands can either change the descriptor directly (for
// alterations that don't require a backfill) or add a mutation to
// the list.
descriptorChanged := false
pkg/sql/alter_table.go
line 1961 at r6 (raw file):
Previously, Xiang-Gu (Xiang Gu) wrote…
super nit: "enqueue TTL mutation ..." might be better since the direction might be add or drop.
I took this from the function name I am calling (AddModifyRowLevelTTLMutation
) the function calling handleTTLStorageParamChange
also refers to it as "add a mutation" so can you file a separate issue to rename it everwhere?
scheduleID and createStmt indexes used to populate slice literals for show results. Rename these to avoid accidental usage and to prevent shadowing in the sql package. Release note: None
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.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @chrisseto and @ecwall)
pkg/sql/alter_table.go
line 1958 at r6 (raw file):
Previously, ecwall (Evan Wall) wrote…
I took this name from
descriptorChanged
at the call site. If you want to change this, can you file a separate issue?The call site documents that
descriptorChanged
should be true only if no mutations are added so it should be changed there also.// Commands can either change the descriptor directly (for // alterations that don't require a backfill) or add a mutation to // the list. descriptorChanged := false
I think descriptorChanged
means is there any updates made to the descriptor. We further make updates into two categories:
1). enqueue a mutation to the descriptor's mutation slice
2). modify other fields directly in the descriptor
In handleTTLStorageParamChange
, descriptorChanged is not correctly set according to this standard. For example, it's set to false when we enqueue a mutation. That's why I suggested we should rename the variable (within handleTTLStorageParamChange
) to something like canDirectlyModifyDescriptor
. And that's also why the return value of handleTTLStorageParamChange
should be something like canDirectlyModifyDescriptor || hasEnqueuedAnyMutation
. Nothing outside handleTTLStorageParamChange
should change.
Split large subtests into smaller subtests to make debugging easier. Release note: None
Fixes #109138 Previously running `RESET (ttl_expire_after)` would remove all table TTL settings if `ttl_expiration_expression` was set. This PR fixes the schema changer to only remove all TTL settings on `RESET (ttl)`. Release note (bug fix): `RESET (ttl_expire_after)` no longer incorrectly removes `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.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @chrisseto and @Xiang-Gu)
pkg/sql/alter_table.go
line 1958 at r6 (raw file):
Previously, Xiang-Gu (Xiang Gu) wrote…
I think
descriptorChanged
means is there any updates made to the descriptor. We further make updates into two categories:
1). enqueue a mutation to the descriptor's mutation slice
2). modify other fields directly in the descriptorIn
handleTTLStorageParamChange
, descriptorChanged is not correctly set according to this standard. For example, it's set to false when we enqueue a mutation. That's why I suggested we should rename the variable (withinhandleTTLStorageParamChange
) to something likecanDirectlyModifyDescriptor
. And that's also why the return value ofhandleTTLStorageParamChange
should be something likecanDirectlyModifyDescriptor || hasEnqueuedAnyMutation
. Nothing outsidehandleTTLStorageParamChange
should change.
Please make another ticket to address this with example(s) of where it is being set to true when a mutation is added. Based on the usage of descriptorChanged
, it only needs to be set if no mutations are added:
cockroach/pkg/sql/alter_table.go
Line 849 in 1755d67
if !addedMutations && !descriptorChanged { |
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.
I will take a look at the examples. LGTM! Good work!
bors r=Xiang-Gu |
Build succeeded: |
Encountered an error creating backports. Some common things that can go wrong:
You might need to create your backport manually using the backport tool. error creating merge commit from 3e7bb4b to blathers/backport-release-22.1-110252: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict [] you may need to manually resolve merge conflicts with the backport tool. Backport to branch 22.1.x failed. See errors above. error creating merge commit from 5fba729 to blathers/backport-release-23.1-110252: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict [] you may need to manually resolve merge conflicts with the backport tool. Backport to branch 23.1.x failed. See errors above. error creating merge commit from 5fba729 to blathers/backport-release-23.1.11-rc-110252: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict [] you may need to manually resolve merge conflicts with the backport tool. Backport to branch 23.1.11-rc failed. See errors above. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
Fixes #109138
Previously running
RESET (ttl_expire_after)
would remove all table TTLsettings if
ttl_expiration_expression
was set.This PR fixes the schema changer to only remove all TTL settings on
RESET (ttl)
.Release note (bug fix):
RESET (ttl_expire_after)
no longer incorrectlyremoves
ttl_expiration_expression
.