diff --git a/go/vt/mysqlctl/builtinbackupengine.go b/go/vt/mysqlctl/builtinbackupengine.go index 09323c9387b..525b8578d44 100644 --- a/go/vt/mysqlctl/builtinbackupengine.go +++ b/go/vt/mysqlctl/builtinbackupengine.go @@ -606,6 +606,16 @@ func (be *BuiltinBackupEngine) ExecuteRestore(ctx context.Context, params Restor // restoreFiles will copy all the files from the BackupStorage to the // right place. func (be *BuiltinBackupEngine) restoreFiles(ctx context.Context, params RestoreParams, bh backupstorage.BackupHandle, bm builtinBackupManifest) error { + // For optimization, we are replacing pargzip with pgzip, so newBuiltinDecompressor doesn't have to compare and print warning for every file + // since newBuiltinDecompressor is helper method and does not hold any state, it was hard to do it in that method itself. + if bm.CompressionEngine == PargzipCompressor { + params.Logger.Warningf(`engine "pargzip" doesn't support decompression, using "pgzip" instead`) + bm.CompressionEngine = PgzipCompressor + defer func() { + bm.CompressionEngine = PargzipCompressor + }() + } + fes := bm.FileEntries sema := sync2.NewSemaphore(params.Concurrency, 0) rec := concurrency.AllErrorRecorder{} diff --git a/go/vt/mysqlctl/compression.go b/go/vt/mysqlctl/compression.go index 40c4dc344a3..3d6b017a70b 100644 --- a/go/vt/mysqlctl/compression.go +++ b/go/vt/mysqlctl/compression.go @@ -193,7 +193,7 @@ func newExternalDecompressor(ctx context.Context, cmdStr string, reader io.Reade // This returns a reader that will decompress the underlying provided reader and will use the specified supported engine. func newBuiltinDecompressor(engine string, reader io.Reader, logger logutil.Logger) (decompressor io.ReadCloser, err error) { if engine == PargzipCompressor { - logger.Warningf("engine \"pargzip\" doesn't support decompression, using \"pgzip\" instead") + logger.Warningf(`engine "pargzip" doesn't support decompression, using "pgzip" instead`) engine = PgzipCompressor } diff --git a/go/vt/mysqlctl/xtrabackupengine.go b/go/vt/mysqlctl/xtrabackupengine.go index d0d131e3cee..112bdf4179d 100644 --- a/go/vt/mysqlctl/xtrabackupengine.go +++ b/go/vt/mysqlctl/xtrabackupengine.go @@ -451,7 +451,6 @@ func (be *XtrabackupEngine) ExecuteRestore(ctx context.Context, params RestorePa func (be *XtrabackupEngine) restoreFromBackup(ctx context.Context, cnf *Mycnf, bh backupstorage.BackupHandle, bm xtraBackupManifest, logger logutil.Logger) error { // first download the file into a tmp dir // and extract all the files - tempDir := fmt.Sprintf("%v/%v", cnf.TmpDir, time.Now().UTC().Format("xtrabackup-2006-01-02.150405")) // create tempDir if err := os.MkdirAll(tempDir, os.ModePerm); err != nil { @@ -465,6 +464,16 @@ func (be *XtrabackupEngine) restoreFromBackup(ctx context.Context, cnf *Mycnf, b } }(tempDir, logger) + // For optimization, we are replacing pargzip with pgzip, so newBuiltinDecompressor doesn't have to compare and print warning for every file + // since newBuiltinDecompressor is helper method and does not hold any state, it was hard to do it in that method itself. + if bm.CompressionEngine == PargzipCompressor { + logger.Warningf(`engine "pargzip" doesn't support decompression, using "pgzip" instead`) + bm.CompressionEngine = PgzipCompressor + defer func() { + bm.CompressionEngine = PargzipCompressor + }() + } + if err := be.extractFiles(ctx, logger, bh, bm, tempDir); err != nil { logger.Errorf("error extracting backup files: %v", err) return err