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

builtinbackup: log during restore as restore, not as backup #16483

Merged
merged 2 commits into from
Jul 26, 2024
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
2 changes: 1 addition & 1 deletion go/test/endtoend/backup/vtctlbackup/backup_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ func verifySemiSyncStatus(t *testing.T, vttablet *cluster.Vttablet, expectedStat
}

func terminateBackup(t *testing.T, alias string) {
stopBackupMsg := "Done taking Backup"
stopBackupMsg := "Completed backing up"
if useXtrabackup {
stopBackupMsg = "Starting backup with"
useXtrabackup = false
Expand Down
16 changes: 10 additions & 6 deletions go/vt/mysqlctl/builtinbackupengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -766,21 +766,25 @@ func (bp *backupPipe) HashString() string {
return hex.EncodeToString(bp.crc32.Sum(nil))
}

func (bp *backupPipe) ReportProgress(period time.Duration, logger logutil.Logger) {
func (bp *backupPipe) ReportProgress(period time.Duration, logger logutil.Logger, restore bool) {
messageStr := "restoring "
deepthi marked this conversation as resolved.
Show resolved Hide resolved
if !restore {
messageStr = "backing up "
}
tick := time.NewTicker(period)
defer tick.Stop()
for {
select {
case <-bp.done:
logger.Infof("Done taking Backup %q", bp.filename)
logger.Infof("Completed %s %q", messageStr, bp.filename)
return
case <-tick.C:
written := float64(atomic.LoadInt64(&bp.nn))
if bp.maxSize == 0 {
logger.Infof("Backup %q: %.02fkb", bp.filename, written/1024.0)
logger.Infof("%s %q: %.02fkb", messageStr, bp.filename, written/1024.0)
} else {
maxSize := float64(bp.maxSize)
logger.Infof("Backup %q: %.02f%% (%.02f/%.02fkb)", bp.filename, 100.0*written/maxSize, written/1024.0, maxSize/1024.0)
logger.Infof("%s %q: %.02f%% (%.02f/%.02fkb)", messageStr, bp.filename, 100.0*written/maxSize, written/1024.0, maxSize/1024.0)
}
}
}
Expand Down Expand Up @@ -813,7 +817,7 @@ func (be *BuiltinBackupEngine) backupFile(ctx context.Context, params BackupPara
}

br := newBackupReader(fe.Name, fi.Size(), timedSource)
go br.ReportProgress(builtinBackupProgress, params.Logger)
go br.ReportProgress(builtinBackupProgress, params.Logger, false /*restore*/)

// Open the destination file for writing, and a buffer.
params.Logger.Infof("Backing up file: %v", fe.Name)
Expand Down Expand Up @@ -1078,7 +1082,7 @@ func (be *BuiltinBackupEngine) restoreFile(ctx context.Context, params RestorePa
}()

br := newBackupReader(name, 0, timedSource)
go br.ReportProgress(builtinBackupProgress, params.Logger)
go br.ReportProgress(builtinBackupProgress, params.Logger, true /*restore*/)
var reader io.Reader = br

// Open the destination file for writing.
Expand Down
Loading