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

release-20.2: sql: fix or disallow TRUNCATE and concurrent schema changes #63153

Merged
merged 1 commit into from
Apr 20, 2021

Conversation

ajwerner
Copy link
Contributor

@ajwerner ajwerner commented Apr 6, 2021

Backport 1/1 commits from #62944.

/cc @cockroachdb/release


Prior to this change, the truncate implementation since 20.2 was totally
broken. The code creates new indexes for all existing indexes. It also
makes all mutations public. The problem with this is that it makes the
mutations public after deciding which indexes to clone. Because of this
it just makes currently being backfilled or validated indexes public. This
leads to inconsistency between the old secondary index and the newly
truncated indexes.

The code is also problematic in that it does not do anything about the mutation
jobs. The code assumes that these jobs will happily continue and detect that
they correspond to no mutations and stop doing things as well as clean
themselves up. Unfortunately, it seems that these changes can lead to certain
failures. For example, new index validation may now fail. Reverting that index
build will now also fail because the index is public. This will leave the
descriptor in a state where it has an orphaned mutation job. We fix this by
only permitting TRUNCATE to run concurrently with mutations we deem safe and
then to fix the behavior for those cases.

Fixes #62842.

Release note (bug fix): Fixed bugs where TRUNCATE concurrent with index
construction and other schema changes could result in corruption.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@ajwerner ajwerner force-pushed the backport20.2-62944 branch from b3971ff to 2ed3db1 Compare April 6, 2021 20:25
@ajwerner ajwerner force-pushed the backport20.2-62944 branch from 2ed3db1 to 122b161 Compare April 20, 2021 03:45
@ajwerner ajwerner requested a review from jordanlewis April 20, 2021 03:45
…ma changes

Prior to this change, the truncate implementation since 20.2 was totally
broken. The code creates new indexes for all existing indexes. It also
makes all mutations public. The problem with this is that it makes the
mutations public *after* deciding which indexes to clone. Because of this
it just makes currently being backfilled or validated indexes public. This
leads to inconsistency between the old secondary index and the newly
truncated indexes.

The code is also problematic in that it does not do anything about the mutation
jobs. The code assumes that these jobs will happily continue and detect that
they correspond to no mutations and stop doing things as well as clean
themselves up. Unfortunately, it seems that these changes can lead to certain
failures. For example, new index validation may now fail. Reverting that index
build will now also fail because the index is public. This will leave the
descriptor in a state where it has an orphaned mutation job. We fix this by
only permitting TRUNCATE to run concurrently with mutations we deem safe and
then to fix the behavior for those cases.

Fixes cockroachdb#62842.

Release note (bug fix): Fixed bugs where TRUNCATE concurrent with index
construction and other schema changes could result in corruption.
@ajwerner ajwerner force-pushed the backport20.2-62944 branch from 122b161 to 8575997 Compare April 20, 2021 13:47
@ajwerner ajwerner merged commit 31ef476 into cockroachdb:release-20.2 Apr 20, 2021
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