Skip to content

sql: drop types as part of a DROP DATABASE statement#51362

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
rohany:drop-db-with-types
Aug 5, 2020
Merged

sql: drop types as part of a DROP DATABASE statement#51362
craig[bot] merged 1 commit intocockroachdb:masterfrom
rohany:drop-db-with-types

Conversation

@rohany
Copy link
Copy Markdown
Contributor

@rohany rohany commented Jul 13, 2020

Fixes #49940.

This commit adds logic to drop all types as part of a DROP DATABASE
cascade.

Release note: None

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@rohany rohany force-pushed the drop-db-with-types branch 2 times, most recently from e1b7dda to 8443cf5 Compare July 16, 2020 20:37
@rohany rohany marked this pull request as ready for review July 16, 2020 20:38
@rohany rohany requested review from ajwerner and thoszhang July 16, 2020 20:38
@rohany
Copy link
Copy Markdown
Contributor Author

rohany commented Jul 16, 2020

Take a look at the second commit please!

@rohany rohany force-pushed the drop-db-with-types branch 2 times, most recently from e74341a to a0b7e1e Compare July 20, 2020 14:50
@rohany rohany force-pushed the drop-db-with-types branch 2 times, most recently from 642c56e to f72ec2b Compare July 28, 2020 16:46
@rohany
Copy link
Copy Markdown
Contributor Author

rohany commented Jul 28, 2020

I've rebased this and it's ready for review

@rohany
Copy link
Copy Markdown
Contributor Author

rohany commented Aug 3, 2020

pinging @ajwerner and @lucy-zhang for review.

Copy link
Copy Markdown

@thoszhang thoszhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 3 of 10 files at r2, 21 of 21 files at r3.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner and @rohany)


pkg/sql/drop_table.go, line 324 at r3 (raw file):

	// queued. If not, then the job that is handling the drop table will also
	// clean up all of the types to be dropped.
	if queueJob {

This parameter currently just indicates whether the object is being dropped as part of DROP DATABASE CASCADE, right? Maybe we should rename it accordingly. It's a little strange to have other behavior depend on the queueJob parameter.


pkg/sql/schema_changer.go, line 1793 at r3 (raw file):

	// multiple tables in a single job (e.g., TRUNCATE on multiple tables), so
	// it's possible for DroppedDatabaseID to be unset.
	if details.DroppedDatabaseID != sqlbase.InvalidID || len(details.DroppedTables) > 1 || len(details.DroppedTypes) > 0 {

When would DroppedTypes be non-nil when DroppedDatabaseID is unset?


pkg/sql/logictest/testdata/logic_test/drop_type, line 1 at r3 (raw file):

# LogicTest: !3node-tenant

Why the configuration change? Does the current incoherent caching of databases make DROP DATABASE in logic tests in multi-node configurations unreliable or something?


pkg/sql/logictest/testdata/logic_test/drop_type, line 295 at r3 (raw file):

DROP DATABASE d RESTRICT

let $t_id

Interesting, I didn't know we supported this

@rohany rohany force-pushed the drop-db-with-types branch from f72ec2b to d033b25 Compare August 3, 2020 17:14
Copy link
Copy Markdown
Contributor Author

@rohany rohany left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner, @lucy-zhang, and @rohany)


pkg/sql/drop_table.go, line 324 at r3 (raw file):

Previously, lucy-zhang (Lucy Zhang) wrote…

This parameter currently just indicates whether the object is being dropped as part of DROP DATABASE CASCADE, right? Maybe we should rename it accordingly. It's a little strange to have other behavior depend on the queueJob parameter.

Good point, done.


pkg/sql/schema_changer.go, line 1793 at r3 (raw file):

Previously, lucy-zhang (Lucy Zhang) wrote…

When would DroppedTypes be non-nil when DroppedDatabaseID is unset?

Yeah, I don't think there is a case for that.


pkg/sql/logictest/testdata/logic_test/drop_type, line 1 at r3 (raw file):

Previously, lucy-zhang (Lucy Zhang) wrote…

Why the configuration change? Does the current incoherent caching of databases make DROP DATABASE in logic tests in multi-node configurations unreliable or something?

There's some known issues with DROP DATABASE not working in the multitenant config due to some errors with range deletes.

Fixes cockroachdb#49940.

This commit adds logic to drop all types as part of a `DROP DATABASE`
cascade.

Release note: None
@rohany rohany force-pushed the drop-db-with-types branch from d033b25 to b409508 Compare August 4, 2020 03:21
@rohany rohany requested a review from thoszhang August 4, 2020 17:09
Copy link
Copy Markdown

@thoszhang thoszhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 14 of 14 files at r4.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @ajwerner and @rohany)

@rohany
Copy link
Copy Markdown
Contributor Author

rohany commented Aug 5, 2020

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Aug 5, 2020

Build succeeded:

@craig craig bot merged commit d500615 into cockroachdb:master Aug 5, 2020
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: drop types when a database is dropped

3 participants