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: mitigate impact of corrupted back-references in type descriptor #84322

Open
postamar opened this issue Jul 12, 2022 · 0 comments
Open

sql: mitigate impact of corrupted back-references in type descriptor #84322

postamar opened this issue Jul 12, 2022 · 0 comments
Labels
A-schema-changer-impl Related to the implementation of the new schema changer C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)

Comments

@postamar
Copy link
Contributor

postamar commented Jul 12, 2022

In #84144 we have one such instance: ALTER TABLE ... SET LOCALITY REGIONAL BY ROW forgot to add a back-reference to the table in the type, and a subsequent DROP REGION succeeds, with dire consequences to the table.

This issue tracks adding more validation checks to DROP REGION to correctly trigger an error on clusters whose type descriptors are already corrupted.

Preliminary work for #63161 revealed another potential instance of this class of error when altering a column's type from one enum type to another. This issue also tracks doing the same for those in 22.1 and perhaps 21.2 also.

This is all assuming that 22.2 will be unaffected because #63161 will be completed in time for the release.

Jira issue: CRDB-17586

Epic CRDB-31164

@postamar postamar added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. A-schema-changer-impl Related to the implementation of the new schema changer labels Jul 12, 2022
@blathers-crl blathers-crl bot added the T-sql-schema-deprecated Use T-sql-foundations instead label Jul 12, 2022
postamar pushed a commit to postamar/cockroach that referenced this issue Jul 13, 2022
This commit fixes a long-standing bug in which making an existing
multi-region table REGIONAL BY ROW would omit adding a back-reference to
the table in the region enum type. This puts the table at risk for
corruption in the face of schema changes to the region enum, which is
unaware of this dependency.

Informs cockroachdb#84144.

Release note (bug fix): fixes bug where ALTER TABLE ... SET LOCALITY
REGIONAL BY ROW could leave the region enum type descriptor unaware of
a dependency on the altered table. This would, in turn, wrongly permit
a DROP REGION to succeed, rendering the table unusable. Note that this
fix does not help existing clusters which have already run such an ALTER
TABLE; see cockroachdb#84322 for that.
postamar pushed a commit to postamar/cockroach that referenced this issue Jul 13, 2022
This commit is featured only in the release-22.1 branch and
repairs missing table back-references in the region enum type descriptor
before performing a DROP REGION or DROP SUPER REGION.

Partially addresses cockroachdb#84322.

See also cockroachdb#84144.

Release note: None
@postamar postamar self-assigned this Jul 13, 2022
@postamar postamar removed their assignment Sep 16, 2022
@exalate-issue-sync exalate-issue-sync bot added T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) and removed T-sql-schema-deprecated Use T-sql-foundations instead labels May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-schema-changer-impl Related to the implementation of the new schema changer C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Projects
None yet
Development

No branches or pull requests

1 participant