From 6fc2b1df68b7752e30200a3770fffb961a20fe6c Mon Sep 17 00:00:00 2001 From: deepthi Date: Fri, 11 Jun 2021 13:48:58 -0700 Subject: [PATCH] workaround xtrabackup error using mysql global variable old_alter_table Signed-off-by: deepthi --- go/test/endtoend/recovery/unshardedrecovery/recovery.go | 5 +++++ go/vt/mysqlctl/xtrabackupengine.go | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/go/test/endtoend/recovery/unshardedrecovery/recovery.go b/go/test/endtoend/recovery/unshardedrecovery/recovery.go index 336b46812a7..370e2b7fb75 100644 --- a/go/test/endtoend/recovery/unshardedrecovery/recovery.go +++ b/go/test/endtoend/recovery/unshardedrecovery/recovery.go @@ -100,6 +100,11 @@ func TestMainImpl(m *testing.M) { sql := string(initDb) newInitDBFile = path.Join(localCluster.TmpDirectory, "init_db_with_passwords.sql") sql = sql + initialsharding.GetPasswordUpdateSQL(localCluster) + // https://github.com/vitessio/vitess/issues/8315 + oldAlterTableMode := ` +SET GLOBAL old_alter_table = ON; +` + sql = sql + oldAlterTableMode ioutil.WriteFile(newInitDBFile, []byte(sql), 0666) extraArgs := []string{"-db-credentials-file", dbCredentialFile} diff --git a/go/vt/mysqlctl/xtrabackupengine.go b/go/vt/mysqlctl/xtrabackupengine.go index d1935acb144..62153303ff5 100644 --- a/go/vt/mysqlctl/xtrabackupengine.go +++ b/go/vt/mysqlctl/xtrabackupengine.go @@ -299,6 +299,7 @@ func (be *XtrabackupEngine) backupFiles(ctx context.Context, params BackupParams // the replication position. Note that if we don't read stderr as we go, the // xtrabackup process gets blocked when the write buffer fills up. stderrBuilder := &strings.Builder{} + posBuilder := &strings.Builder{} stderrDone := make(chan struct{}) go func() { defer close(stderrDone) @@ -308,6 +309,7 @@ func (be *XtrabackupEngine) backupFiles(ctx context.Context, params BackupParams for scanner.Scan() { line := scanner.Text() params.Logger.Infof("xtrabackup stderr: %s", line) + fmt.Fprintln(stderrBuilder, line) // Wait until we see the first line of the binlog position. // Then capture all subsequent lines. We need multiple lines since @@ -318,7 +320,7 @@ func (be *XtrabackupEngine) backupFiles(ctx context.Context, params BackupParams } capture = true } - fmt.Fprintln(stderrBuilder, line) + fmt.Fprintln(posBuilder, line) } if err := scanner.Err(); err != nil { params.Logger.Errorf("error reading from xtrabackup stderr: %v", err) @@ -362,7 +364,8 @@ func (be *XtrabackupEngine) backupFiles(ctx context.Context, params BackupParams return replicationPosition, vterrors.Wrap(err, fmt.Sprintf("xtrabackup failed with error. Output=%s", sterrOutput)) } - replicationPosition, rerr := findReplicationPosition(sterrOutput, flavor, params.Logger) + posOutput := posBuilder.String() + replicationPosition, rerr := findReplicationPosition(posOutput, flavor, params.Logger) if rerr != nil { return replicationPosition, vterrors.Wrap(rerr, "backup failed trying to find replication position") }