Skip to content

Commit

Permalink
Add retry in copy (#310)
Browse files Browse the repository at this point in the history
Signed-off-by: wayblink <[email protected]>
  • Loading branch information
wayblink authored Mar 7, 2024
1 parent 86ed608 commit 8c34a47
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 8 additions & 4 deletions core/backup_impl_create_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -747,9 +747,11 @@ func (b *BackupContext) copySegments(ctx context.Context, segments []*backuppb.S
return err
}

err = b.getStorageClient().Copy(ctx, b.milvusBucketName, b.backupBucketName, binlog.GetLogPath(), targetPath)
err = retry.Do(ctx, func() error {
return b.getStorageClient().Copy(ctx, b.milvusBucketName, b.backupBucketName, binlog.GetLogPath(), targetPath)
}, retry.Sleep(2*time.Second), retry.Attempts(5))
if err != nil {
log.Info("Fail to copy file",
log.Info("Fail to copy file after retry",
zap.Error(err),
zap.String("from", binlog.GetLogPath()),
zap.String("to", targetPath))
Expand Down Expand Up @@ -795,9 +797,11 @@ func (b *BackupContext) copySegments(ctx context.Context, segments []*backuppb.S
zap.String("file", binlog.GetLogPath()))
return errors.New("Binlog file not exist " + binlog.GetLogPath())
}
err = b.getStorageClient().Copy(ctx, b.milvusBucketName, b.backupBucketName, binlog.GetLogPath(), targetPath)
err = retry.Do(ctx, func() error {
return b.getStorageClient().Copy(ctx, b.milvusBucketName, b.backupBucketName, binlog.GetLogPath(), targetPath)
}, retry.Sleep(2*time.Second), retry.Attempts(5))
if err != nil {
log.Info("Fail to copy file",
log.Info("Fail to copy file after retry",
zap.Error(err),
zap.String("from", binlog.GetLogPath()),
zap.String("to", targetPath))
Expand Down
6 changes: 4 additions & 2 deletions core/backup_impl_restore_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,9 +623,11 @@ func (b *BackupContext) restorePartition(ctx context.Context, targetDBName, targ
realFiles[i] = file
} else {
log.Debug("Copy temporary restore file", zap.String("from", file), zap.String("to", tempDir+file))
err := b.getStorageClient().Copy(ctx, backupBucketName, b.milvusBucketName, file, tempDir+file)
err = retry.Do(ctx, func() error {
return b.getStorageClient().Copy(ctx, backupBucketName, b.milvusBucketName, file, tempDir+file)
}, retry.Sleep(2*time.Second), retry.Attempts(5))
if err != nil {
log.Error("fail to copy backup date from backup bucket to restore target milvus bucket", zap.Error(err))
log.Error("fail to copy backup date from backup bucket to restore target milvus bucket after retry", zap.Error(err))
return err
}
realFiles[i] = tempDir + file
Expand Down

0 comments on commit 8c34a47

Please sign in to comment.