release-20.1: sqlmigrations: fix handling of mutations in schema change job migration #48838
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport 1/1 commits from #48823.
/cc @cockroachdb/release
The migration for schema change jobs assumed that a table descriptor's
MutationJobs
were always synced withMutations
, so we were indexinginto
Mutations
with theMutationJobs
index. In practice, if thisassumption doesn't hold due to some previous buggy schema change, we
risk crashing with an out of bounds error or looking up the wrong
mutation. This PR adds a step to find the mutation with the expected ID
and mark the job as failed if the mutation doesn't exist.
Fixes #48786.
Release note (bug fix): Fix a problem introduced in v20.1.0 where the
migration for ongoing schema change jobs would cause the node to panic
with an index out of bounds error, upon encountering a malformed table
descriptor with no schema change mutation corresponding to the job to be
migrated.