Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pitr: move step iterate backup files into worker pool #40577

Merged
merged 3 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions br/pkg/restore/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2043,34 +2043,36 @@ func (rc *Client) RestoreKVFiles(
log.Debug("skip file due to table id not matched", zap.Int64("table-id", files[0].TableId))
skipFile += len(files)
} else {
rc.workerPool.ApplyOnErrorGroup(eg, func() error {
rc.workerPool.ApplyOnErrorGroup(eg, func() (err error) {
fileStart := time.Now()
defer func() {
onProgress(int64(len(files)))
updateStats(uint64(kvCount), size)
summary.CollectInt("File", len(files))

filenames := make([]string, 0, len(files))
for _, f := range files {
filenames = append(filenames, f.Path+", ")
if err == nil {
filenames := make([]string, 0, len(files))
for _, f := range files {
filenames = append(filenames, f.Path+", ")
}
log.Info("import files done", zap.Int("batch-count", len(files)), zap.Uint64("batch-size", size),
zap.Duration("take", time.Since(fileStart)), zap.Strings("files", filenames))
}
log.Info("import files done", zap.Int("batch-count", len(files)), zap.Uint64("batch-size", size),
zap.Duration("take", time.Since(fileStart)), zap.Strings("files", filenames))
}()

return rc.fileImporter.ImportKVFiles(ectx, files, rule, rc.shiftStartTS, rc.startTS, rc.restoreTS, supportBatch)
})
}
}

if supportBatch {
err = ApplyKVFilesWithBatchMethod(ectx, iter, int(pitrBatchCount), uint64(pitrBatchSize), applyFunc)
} else {
err = ApplyKVFilesWithSingelMethod(ectx, iter, applyFunc)
}
if err != nil {
rc.workerPool.ApplyOnErrorGroup(eg, func() error {
if supportBatch {
err = ApplyKVFilesWithBatchMethod(ectx, iter, int(pitrBatchCount), uint64(pitrBatchSize), applyFunc)
} else {
err = ApplyKVFilesWithSingelMethod(ectx, iter, applyFunc)
}
return errors.Trace(err)
}
})

log.Info("total skip files due to table id not matched", zap.Int("count", skipFile))
if skipFile > 0 {
Expand Down
3 changes: 2 additions & 1 deletion br/pkg/task/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,8 @@ func (cfg *RestoreConfig) adjustRestoreConfigForStreamRestore() {
if cfg.PitrBatchSize == 0 {
cfg.PitrBatchSize = defaultPiTRBatchSize
}

// another goroutine is used to iterate the backup file
cfg.PitrConcurrency += 1
log.Info("set restore kv files concurrency", zap.Int("concurrency", int(cfg.PitrConcurrency)))
cfg.Config.Concurrency = cfg.PitrConcurrency
}
Expand Down