-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
19.2: sql: TRUNCATE prevents later ALTER TABLE ... RENAME TO ... #50587
Comments
Prior to this commit, we'd populate the DropJobID in both the new and old tables when truncating a table. This causes problems later. Note that this commit does not add robustness to clusters which have table descriptors with a DropJobID due to this bug. That will come in a follow-up. Touches cockroachdb#50587. Release note (bug fix): Fixed a bug in TRUNCATE which could later leave tables in a state where they cannot be renamed.
In cockroachdb#50587 we discovered that TRUNCATE would leave a DropJobID on both the new and old tables. This situation was rectified in cockroachdb#50714. In most cases that job ID is ignored. However, in release-19.2 and earlier, it would prevent RENAME operations from completing. To deal with this, we repair the descriptor by removing the DropJobID. We also, for additional protection, prevent the failure to update the job from preventing progress. Release note (bug fix): Fixed a bug which could prevent previously TRUNCATED tables from being renamed.
In cockroachdb#50587 we discovered that TRUNCATE would leave a DropJobID on both the new and old tables. This situation was rectified in cockroachdb#50714. In most cases that job ID is ignored. However, in release-19.2 and earlier, it would prevent RENAME operations from completing. To deal with this, we repair the descriptor by removing the DropJobID. We also, for additional protection, prevent the failure to update the job from preventing progress. Release note (bug fix): Fixed a bug which could prevent previously TRUNCATED tables from being renamed.
I have some lingering concerns about the job upgrade migration that I'm working through. I'm curious to what extent this bug relates to #49876 which I'm still investigating. |
Prior to this commit, we'd populate the DropJobID in both the new and old tables when truncating a table. This causes problems later. Note that this commit does not add robustness to clusters which have table descriptors with a DropJobID due to this bug. That will come in a follow-up. Touches cockroachdb#50587. Release note (bug fix): Fixed a bug in TRUNCATE which could later leave tables in a state where they cannot be renamed.
In cockroachdb#50587 we discovered that TRUNCATE would leave a DropJobID on both the new and old tables. This situation was rectified in cockroachdb#50714. In most cases that job ID is ignored. However, in release-19.2 and earlier, it would prevent RENAME operations from completing. To deal with this, we repair the descriptor by removing the DropJobID. We also, for additional protection, prevent the failure to update the job from preventing progress. Release note (bug fix): Fixed a bug which could prevent previously TRUNCATED tables from being renamed.
I'm interested in this, say more when you have time? |
I just wanted to make sure that these DropJobIDs wouldn't cause problems when upgrading. They don't. Nothing to see here. |
Describe the problem
The implementation of TRUNCATE is to create a new table with a new descriptor ID and replace an old table which we'll drop. When we drop the old table, we create a drop job to asynchronously clean up its data. In 19.2 and prior, we'd assign this job ID to the old table prior to copying it for the new table. This means that the new table descriptor will have a populated drop job ID. This populated drop job ID then later prevents renames.
Here's the crazy assignment:
cockroach/pkg/sql/truncate.go
Lines 190 to 191 in ee75989
The problem ends up being here:
W200622 19:46:55.858884 359674971 sql/exec_util.go:1140 [n5,client=10.0.32.19:38956,user=root] error executing schema change: job with ID 559393931270488069 does not exist
To Reproduce
Using 19.2.7 or prior: TRUNCATE a table, set the default GC ttl to 1s, wait for the drop of the old table to succeed, then try to rename the table.
Expected behavior
We won't write that
DropJobID
and we remain robust to schema changes which try to operate on public tables which have it.Additional context
At this point, we need to do a couple of things:
DropJobID
in the new tableThe text was updated successfully, but these errors were encountered: