Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workaround xtrabackup error with old_alter_table #8317

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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