Skip to content

Commit

Permalink
importccl: only initialize progress fields on first import attempt
Browse files Browse the repository at this point in the history
Release note (bug fix): Fix a bug where IMPORT would incorrectly reset
its progress upon resumption.
  • Loading branch information
pbardea committed Aug 2, 2021
1 parent 701b177 commit 1e9e62c
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions pkg/sql/distsql_plan_csv.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,22 +225,26 @@ func DistIngest(

dsp.FinalizePlan(planCtx, p)

if err := job.FractionProgressed(ctx, nil, /* txn */
func(ctx context.Context, details jobspb.ProgressDetails) float32 {
prog := details.(*jobspb.Progress_Import).Import
prog.ReadProgress = make([]float32, len(from))
prog.ResumePos = make([]int64, len(from))
if prog.SequenceDetails == nil {
prog.SequenceDetails = make([]*jobspb.SequenceDetails, len(from))
for i := range prog.SequenceDetails {
prog.SequenceDetails[i] = &jobspb.SequenceDetails{}
importDetails := job.Progress().Details.(*jobspb.Progress_Import).Import
if importDetails.ReadProgress == nil {
// Initialize the progress metrics on the first attempt.
if err := job.FractionProgressed(ctx, nil, /* txn */
func(ctx context.Context, details jobspb.ProgressDetails) float32 {
prog := details.(*jobspb.Progress_Import).Import
prog.ReadProgress = make([]float32, len(from))
prog.ResumePos = make([]int64, len(from))
if prog.SequenceDetails == nil {
prog.SequenceDetails = make([]*jobspb.SequenceDetails, len(from))
for i := range prog.SequenceDetails {
prog.SequenceDetails[i] = &jobspb.SequenceDetails{}
}
}
}

return 0.0
},
); err != nil {
return roachpb.BulkOpSummary{}, err
return 0.0
},
); err != nil {
return roachpb.BulkOpSummary{}, err
}
}

rowProgress := make([]int64, len(from))
Expand Down

0 comments on commit 1e9e62c

Please sign in to comment.