From 373cf34302def5280be8be47a03062889c04d5ea Mon Sep 17 00:00:00 2001 From: Deepthi Sigireddi Date: Fri, 26 Jul 2024 09:36:41 -0700 Subject: [PATCH] builtinbackup: log during restore as restore, not as backup (#16483) Signed-off-by: deepthi --- .../endtoend/backup/vtctlbackup/backup_utils.go | 2 +- go/vt/mysqlctl/builtinbackupengine.go | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/go/test/endtoend/backup/vtctlbackup/backup_utils.go b/go/test/endtoend/backup/vtctlbackup/backup_utils.go index 707c9010b0c..3a0150cc87c 100644 --- a/go/test/endtoend/backup/vtctlbackup/backup_utils.go +++ b/go/test/endtoend/backup/vtctlbackup/backup_utils.go @@ -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 diff --git a/go/vt/mysqlctl/builtinbackupengine.go b/go/vt/mysqlctl/builtinbackupengine.go index e388912783a..494d765f2a9 100644 --- a/go/vt/mysqlctl/builtinbackupengine.go +++ b/go/vt/mysqlctl/builtinbackupengine.go @@ -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 " + 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) } } } @@ -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) @@ -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.