Skip to content

Commit

Permalink
workaround xtrabackup error using mysql global variable old_alter_table
Browse files Browse the repository at this point in the history
Signed-off-by: deepthi <[email protected]>
  • Loading branch information
deepthi committed Jun 11, 2021
1 parent ef711fe commit 6fc2b1d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 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
7 changes: 5 additions & 2 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 @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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")
}
Expand Down

0 comments on commit 6fc2b1d

Please sign in to comment.