Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
51848: backupccl: stop reading on MutationJobs on RESTORE r=pbardea a=pbardea

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.

Co-authored-by: Paul Bardea <[email protected]>
  • Loading branch information
craig[bot] and pbardea committed Jul 28, 2020
2 parents a52fa0e + 83218f1 commit 7e36e68
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 7e36e68

Please sign in to comment.