Skip to content

Commit

Permalink
backupccl: stop reading on MutationJobs on RESTORE
Browse files Browse the repository at this point in the history
This change stops reading the MutationJobs field on table descriptors
that we are importing. It previously assumed that the MutationsJobs and
Mutations remain in sync. However, in practice there are descriptors
where this is not the case and RESTORE should no longer rely on this
assumption.

Release note (bug fix): Increase robustness of restore against
descriptors which may be in an unexpected state.
  • Loading branch information
pbardea committed Jul 27, 2020
1 parent 81cc169 commit 83218f1
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions pkg/ccl/backupccl/restore_schema_change_creation.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,18 @@ func createSchemaChangeJobsFromMutations(
username string,
tableDesc *sqlbase.TableDescriptor,
) ([]*jobs.StartableJob, error) {
mutationJobs := make([]sqlbase.TableDescriptor_MutationJob, 0, len(tableDesc.MutationJobs))
newJobs := make([]*jobs.StartableJob, 0, len(tableDesc.MutationJobs))
for _, mj := range tableDesc.MutationJobs {
mutationID := mj.MutationID
jobDesc, mutationCount, err := jobDescriptionFromMutationID(tableDesc, mj.MutationID)
mutationJobs := make([]sqlbase.TableDescriptor_MutationJob, 0, len(tableDesc.Mutations))
newJobs := make([]*jobs.StartableJob, 0, len(tableDesc.Mutations))
seenMutations := make(map[sqlbase.MutationID]bool)
for _, mutation := range tableDesc.Mutations {
if seenMutations[mutation.MutationID] {
// We've already seen a mutation with this ID, so a job that handles all
// mutations with this ID has already been created.
continue
}
mutationID := mutation.MutationID
seenMutations[mutationID] = true
jobDesc, mutationCount, err := jobDescriptionFromMutationID(tableDesc, mutationID)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 83218f1

Please sign in to comment.