Skip to content

sql: resolve error due to drop table after schema change in same txn#56589

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
jayshrivastava:resolve-existing-jobs-on-drop-table
Nov 12, 2020
Merged

sql: resolve error due to drop table after schema change in same txn#56589
craig[bot] merged 1 commit intocockroachdb:masterfrom
jayshrivastava:resolve-existing-jobs-on-drop-table

Conversation

@jayshrivastava
Copy link
Copy Markdown
Contributor

Previously, if a drop table statement was executed in a transaction
following other schema changes to the table in the same transaction,
an error would occur. This error was due to the drop table statement
marking previous jobs as succeeded and then proceeding to modify them.
This change ensures that drop table statement will delete all existing
jobs from the job cache so that it does not interfere with previous jobs.

Release note (sql change): A table can successfully be dropped in
a transaction following other schema changes to the table in the
same transaction.

This resolves one of the issues in #56235

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Contributor

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 2 of 2 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @jayshrivastava)


pkg/sql/drop_table.go, line 429 at r1 (raw file):

	// Mark all jobs scheduled for schema changes as successful and delete them
	// from the schema change job cache.

This deserves more commentary to explain why we need to do this.

Previously, if a drop table statement was executed in a transaction
following other schema changes to the table in the same transaction,
an error would occur. This error was due to the drop table statement
marking previous jobs as succeeded and then proceeding to modify them.
This change ensures that drop table statement will delete all existing
jobs from the job cache so that it does not interfere with previous jobs.

Release note (sql change): A table can successfully be dropped in
a transaction following other schema changes to the table in the
same transaction.
@jayshrivastava jayshrivastava force-pushed the resolve-existing-jobs-on-drop-table branch from 23b99c8 to 7039ad8 Compare November 12, 2020 14:55
@jayshrivastava
Copy link
Copy Markdown
Contributor Author

bors r=ajwerner

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Nov 12, 2020

This PR was included in a batch that was canceled, it will be automatically retried

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Nov 12, 2020

Build succeeded:

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.

3 participants