-
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
sql: fix drop database - sequence ownership bug #50744
Conversation
For some reason, the tests I added aren't moving past the |
Note, use the |
9dce950
to
e7cf2ce
Compare
I haven't looked closely at these changes yet, but this sounds potentially bad. Would you mind digging further into what's getting stuck? I wonder if it's related to the jobs. |
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.
Agree that we should dig into what's going wrong with that test config.
The changes look reasonable to me though I don't have a deep understanding of the queueJob
parameter. It would be great for @lucy-zhang to sign off on that change, i.e. that queueJob
is now being set to false when dropping sequences during a DROP DATABASE.
Could you also add analogous tests for DROP DATABASE without CASCADE? Looks like this is not covered right now.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @solongordon)
Couldn't find anything that immediately jumped out w.r.t the 3node-tenant config from the stack traces. Looks like the problem is not related to sequences -- it fails on a db containing a single, regular table as well. I've opened #50840 |
Previously, `DROP DATABASE CASCADE` would not work if the database contained a sequence owned by a table in the database. This would happen because of two separate reasons: - If the sequence was dropped before the table, the table would try to "double drop" the sequence as it owned it; this would result in an error. - If the table was dropped before the sequence, the sequence would try to remove the ownership dependency from the table descriptor, which had already been dropped; this would also result in an error. This PR addresses both these issues separately. Sequences are no longer double dropped when dropping tables. Additionally, no attempt is made to remove the ownership dependency from the table descriptor if the table descriptor has already been dropped. Fixes cockroachdb#50712 Release note (bug fix): `DROP DATABASE CASCADE` now works as expected even when the database has a sequence with an owner in it.
e7cf2ce
to
0ba9148
Compare
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.
Added a test for DROP DATABASE
without CASCADE as well. Should be RFAL.
Note on the queueJob
-- as part of my change, I plumbed it down so that dropping a sequence owned by a table respects the queueJob
of the table that owned it. It doesn't have an affect on the bug.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @lucy-zhang)
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.
Reviewed 4 of 5 files at r1.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @lucy-zhang and @solongordon)
bors r=solongordon |
Build succeeded |
Previously,
DROP DATABASE CASCADE
would not work if the databasecontained a sequence owned by a table in the database. This would
happen because of two separate reasons:
"double drop" the sequence as it owned it; this would result in an
error.
to remove the ownership dependency from the table descriptor, which had
already been dropped; this would also result in an error.
This PR addresses both these issues separately. Sequences are no longer
double dropped when dropping tables. Additionally, no attempt is made
to remove the ownership dependency from the table descriptor if the
table descriptor has already been dropped.
Fixes #50712
Release note (bug fix):
DROP DATABASE CASCADE
now works as expectedeven when the database has a sequence with an owner in it.