Skip to content

Commit

Permalink
Merge pull request #8340 from planetscale/fix-8315-release-9
Browse files Browse the repository at this point in the history
workaround xtrabackup error using mysql global variable old_alter_table
  • Loading branch information
systay authored Jun 15, 2021
2 parents 30f7483 + c25d5f9 commit 5ef7323
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions go/test/endtoend/recovery/unshardedrecovery/recovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
8 changes: 5 additions & 3 deletions go/vt/mysqlctl/xtrabackupengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -318,7 +319,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)
Expand Down Expand Up @@ -359,10 +360,11 @@ func (be *XtrabackupEngine) backupFiles(ctx context.Context, params BackupParams
sterrOutput := stderrBuilder.String()

if err := backupCmd.Wait(); err != nil {
return replicationPosition, vterrors.Wrap(err, "xtrabackup failed with error")
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")
}
Expand Down

0 comments on commit 5ef7323

Please sign in to comment.