Skip to content

tabledesc: improve index column ID and name validation#73142

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
postamar:validate-columns-in-indexes
Jan 24, 2022
Merged

tabledesc: improve index column ID and name validation#73142
craig[bot] merged 1 commit intocockroachdb:masterfrom
postamar:validate-columns-in-indexes

Conversation

@postamar
Copy link
Copy Markdown

@postamar postamar commented Nov 24, 2021

This commit adds missing index column ID and name validation, in
particular concerning stored- and key-suffix-columns.

Fixes #72771.

Release note: None

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@postamar
Copy link
Copy Markdown
Author

postamar commented Nov 24, 2021

This validation is not gated behind any descriptor version formats. Existing corrupted primary indexes will be fixed automatically and so will pass validation, existing corrupted secondary indexes will fail validation and so will require the user to drop them and recreate them.

edit: I got scared for nothing and DROP COLUMN works just fine and so I don't expect any primary index descriptors to be corrupted at all.

@postamar postamar force-pushed the validate-columns-in-indexes branch from ad078c8 to 088bb66 Compare November 25, 2021 15:40
@postamar
Copy link
Copy Markdown
Author

This is interesting. The ADD COLUMN test case in TestRollback is hanging, and this is because we're failing these new validation checks in the rollbacks. I haven't yet found the bug in the declarative schema changer's ADD COLUMN implementation, instead I made some improvements to that test suite so that it wouldn't hang:
#73177

I also made these driven by the side-effects test definitions, which is quite nice here because it makes it easy to see where the problem is. Here, bad things happen when failing the validation ops stage after backfilling.

This commit adds missing index column ID and name validation, in
particular concerning stored- and key-suffix-columns.

Fixes cockroachdb#72771.

Release note: None
@postamar postamar force-pushed the validate-columns-in-indexes branch from 088bb66 to 218f887 Compare January 14, 2022 16:06
@postamar postamar marked this pull request as ready for review January 14, 2022 16:51
@postamar postamar requested a review from a team January 14, 2022 16:51
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, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @postamar)

@postamar
Copy link
Copy Markdown
Author

Thanks for the review!

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jan 24, 2022

Build succeeded:

@craig craig bot merged commit 9e6c361 into cockroachdb:master Jan 24, 2022
@postamar postamar deleted the validate-columns-in-indexes branch January 24, 2022 16:07
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: alter column type can corrupt tables with secondary indexes storing the column

3 participants