Skip to content

Commit

Permalink
Merge pull request #98325 from cockroachdb/blathers/backport-release-…
Browse files Browse the repository at this point in the history
…22.1-98096

release-22.1: backupccl: add some observability to stats insertion during restore
  • Loading branch information
adityamaru authored Mar 29, 2023
2 parents 36a422b + 08565e0 commit ad3d52c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/ccl/backupccl/restore_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -1683,6 +1683,10 @@ func insertStats(
return nil
}

totalNumBatches := len(latestStats) / restoreStatsInsertBatchSize
log.Infof(ctx, "restore will insert %d TableStatistics in %d batches", len(latestStats), totalNumBatches)
insertStatsProgress := log.Every(10 * time.Second)

// We could be restoring hundreds of tables, so insert the new stats in
// batches instead of all in a single, long-running txn. This prevents intent
// buildup in the face of txn retries.
Expand All @@ -1707,6 +1711,7 @@ func insertStats(
if err := job.SetDetails(ctx, txn, details); err != nil {
return errors.Wrapf(err, "updating job marking stats insertion complete")
}
return nil
}

return nil
Expand All @@ -1716,6 +1721,11 @@ func insertStats(

// Truncate the stats that we have inserted in the txn above.
latestStats = latestStats[restoreStatsInsertBatchSize:]

if insertStatsProgress.ShouldLog() {
remainingBatches := len(latestStats) / restoreStatsInsertBatchSize
log.Infof(ctx, "restore has %d/%d TableStatistics batches remaining to insert", remainingBatches, totalNumBatches)
}
}
}

Expand Down

0 comments on commit ad3d52c

Please sign in to comment.