Skip to content
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,importccl: prevent DROP DATABASE CASCADE if there are offline tables #48596

Conversation

ajwerner
Copy link
Contributor

@ajwerner ajwerner commented May 8, 2020

See the issue for more commentary on the problem. In short, we never dropped
offline tables during DROP DATABASE ... CASCADE which would end up leaving
those tables completely orphaned. Orphaned tables with no parent are a problem.

Perhaps it would be better to stop the relevant jobs and then clean up after
them but that's a much more involved fix.

Fixes #48589.

Release note (bug fix): Prevent dropping of databases which contain tables
which are currently offline due to IMPORT or RESTORE. Previously dropping
a database in this state could lead to a corrupted schema which prevented
running backups.

@ajwerner ajwerner requested review from dt and spaskob May 8, 2020 17:32
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@ajwerner ajwerner changed the title sql,importccl: prevent DROP DATABASE ... CASCADE if there are offline… sql,importccl: prevent DROP DATABASE CASCADE if there are offline tables May 8, 2020
@blathers-crl
Copy link

blathers-crl bot commented May 8, 2020

❌ The GitHub CI (Cockroach) build has failed on ecafe0ec.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

… tables

See the issue for more commentary on the problem. In short, we never dropped
offline tables during `DROP DATABASE ... CASCADE` which would end up leaving
those tables completely orphaned. Orphaned tables with no parent are a problem.

Perhaps it would be better to stop the relevant jobs and then clean up after
them but that's a much more involved fix.

Fixes cockroachdb#48589.

Release note (bug fix): Prevent dropping of databases which contain tables
which are currently offline due to `IMPORT` or `RESTORE`. Previously dropping
a database in this state could lead to a corrupted schema which prevented
running backups.
@ajwerner ajwerner force-pushed the ajwerner/fix-drop-cascade-with-offline-tables branch from ecafe0e to a52d50d Compare May 8, 2020 19:01
@ajwerner
Copy link
Contributor Author

ajwerner commented May 8, 2020

TFTR!

bors r=dt

@craig
Copy link
Contributor

craig bot commented May 8, 2020

Build succeeded

@spaskob
Copy link
Contributor

spaskob commented May 8, 2020

Nice - thanks for using a proper pgcode as well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sql: dropping a database with CASCADE with offline tables can result in orphaned tables
4 participants