From 30ec5a09a7ef4a20a61217c700695f78f79ade48 Mon Sep 17 00:00:00 2001 From: Paul Bardea Date: Wed, 4 Aug 2021 09:57:04 -0400 Subject: [PATCH] importccl: reload job progress on retry Release note (bug fix): Fix a bug where IMPORT internal retries (ie due to node failures) may not pick up latest progress updates. --- pkg/ccl/importccl/import_stmt.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pkg/ccl/importccl/import_stmt.go b/pkg/ccl/importccl/import_stmt.go index 430ab56dc2a2..a976a39dd25d 100644 --- a/pkg/ccl/importccl/import_stmt.go +++ b/pkg/ccl/importccl/import_stmt.go @@ -2152,9 +2152,21 @@ func ingestWithRetry( } if utilccl.IsPermanentBulkJobError(err) { - return roachpb.BulkOpSummary{}, err + return res, err } + // Re-load the job in order to update our progress object, which may have + // been updated by the changeFrontier processor since the flow started. + reloadedJob, reloadErr := execCtx.ExecCfg().JobRegistry.LoadJob(ctx, job.ID()) + if reloadErr != nil { + if ctx.Err() != nil { + return res, ctx.Err() + } + log.Warningf(ctx, `IMPORT job %d could not reload job progress when retrying: %+v`, + int64(job.ID()), reloadErr) + } else { + job = reloadedJob + } log.Warningf(ctx, `encountered retryable error: %+v`, err) }