-
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: dropping a sequence with a sequence owners corrupts the table that owns the sequence #50649
Comments
Huh, @RichardJCai found this a bit ago -- #48249 |
I didn't realize that it actually prevents dropping the table that owns the sequence after. |
Previously, when a sequence that was owned by a column was being dropped, we would not remove the sequence ID from the column descriptor of the column that owned it. As a result, there was a bug where if the sequence was dropped manually before the table, it would be impossible to drop the table. This patch addresses this problem by removing the ownership dependency on sequence drops. Fixes cockroachdb#50649 Release note (bug fix): there was a bug previously where if a user created a sequence owned by a table's column and dropped the sequence, it would become impossible to drop the table after. This is now fixed. See attached issue for repro steps.
50665: sql: remove sequence ownership dependency when dropping sequences r=solongordon a=arulajmani Previously, when a sequence that was owned by a column was being dropped, we would not remove the sequence ID from the column descriptor of the column that owned it. As a result, there was a bug where if the sequence was dropped manually before the table, it would be impossible to drop the table. This patch addresses this problem by removing the ownership dependency on sequence drops. Fixes #50649 Release note (bug fix): there was a bug previously where if a user created a sequence owned by a table's column and dropped the sequence, it would become impossible to drop the table after. This is now fixed. See attached issue for repro steps. Co-authored-by: arulajmani <[email protected]>
Previously, when a sequence that was owned by a column was being dropped, we would not remove the sequence ID from the column descriptor of the column that owned it. As a result, there was a bug where if the sequence was dropped manually before the table, it would be impossible to drop the table. This patch addresses this problem by removing the ownership dependency on sequence drops. Fixes cockroachdb#50649 Release note (bug fix): there was a bug previously where if a user created a sequence owned by a table's column and dropped the sequence, it would become impossible to drop the table after. This is now fixed. See attached issue for repro steps.
I'm reopening the issue to discuss how we want to get users' table descriptors out of this state, if they're already in it. This problem (dropped/nonexistent sequence descriptors) is a special case of #50651, but it seems worth bringing up separately. Is there anything targeted we can do to avoid this failure if we hit a dropped/nonexistent sequence while dropping a column or table? Based on a very cursory look at the code, I was wondering if we can just check for cockroach/pkg/sql/drop_sequence.go Line 161 in fe78658
Line 475 in fe78658
|
We've got a related and big problem which is sort of the opposite. Dropping a database which has tables which utilizes sequences corrupts, well, everything. I'll be creating another issue to track that but it's bad. |
I looked into the issue of dropping databases which have tables that utilize sequences and it seems like the table that uses the sequence isn't getting dropped. I don't think that problem is related to this issue though, as there is no "ownership" in that case. The root cause of that issue seems to be I think we can fix this by ensuring |
@arulajmani thanks for taking a look last week. I've written the issue up as #50997 and tentatively assigned it to you. Let me know if you run into any trouble or would like me to look. |
I've opened #51170 for discussion about how to get users' table descriptors out of invalid states if they're already in it. Fixes for a few issues could get users' into invalid states and I've tagged all of them in the issue above. Closing this. |
Previously, when a sequence that was owned by a column was being dropped, we would not remove the sequence ID from the column descriptor of the column that owned it. As a result, there was a bug where if the sequence was dropped manually before the table, it would be impossible to drop the table. This patch addresses this problem by removing the ownership dependency on sequence drops. Fixes cockroachdb#50649 Release note (bug fix): there was a bug previously where if a user created a sequence owned by a table's column and dropped the sequence, it would become impossible to drop the table after. This is now fixed. See attached issue for repro steps.
Repro:
It looks like there is no code to remove the sequence owner ID from the column descriptor that owns the sequence when the sequence is dropped.
The text was updated successfully, but these errors were encountered: