Skip to content

Commit

Permalink
add constant for xtrabackup_info and fix temp name
Browse files Browse the repository at this point in the history
Signed-off-by: 'Renan Rangel' <rrangel@slack-corp.com>
  • Loading branch information
rvrangel committed Jul 1, 2024
1 parent 352af57 commit 1a7995a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions go/vt/mysqlctl/xtrabackupengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const (
writerBufferSize = 2 * 1024 * 1024 /*2 MiB*/
xtrabackupBinaryName = "xtrabackup"
xtrabackupEngineName = "xtrabackup"
xtrabackupInfoFile = "xtrabackup_info"
xbstream = "xbstream"
)

Expand Down Expand Up @@ -293,7 +294,7 @@ func (be *XtrabackupEngine) backupFiles(
flavor string,
) (replicationPosition replication.Position, finalErr error) {
// we create a temporary directory so that xtrabackup can create a copy of xtrabackup_info we can read from later.
tempDir, err := os.MkdirTemp("", "xbstream_vitess_")
tempDir, err := os.MkdirTemp("", "xtrabackup_vitess_")
if err != nil {
return replicationPosition, vterrors.Wrap(err, "unable to create temporary directory")
}
Expand Down Expand Up @@ -750,10 +751,10 @@ func (be *XtrabackupEngine) extractFiles(ctx context.Context, logger logutil.Log
}

func findReplicationPositionFromXtrabackupInfo(directory, flavor string, logger logutil.Logger) (replication.Position, error) {
f, err := os.Open(path.Join(directory, "xtrabackup_info"))
f, err := os.Open(path.Join(directory, xtrabackupInfoFile))
if err != nil {
return replication.Position{}, vterrors.Errorf(vtrpc.Code_INVALID_ARGUMENT,
"couldn't open %q to read GTID position", path.Join(directory, "xtrabackup_info"))
"couldn't open %q to read GTID position", path.Join(directory, xtrabackupInfoFile))
}
defer f.Close()

Expand Down
2 changes: 1 addition & 1 deletion go/vt/mysqlctl/xtrabackupengine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestFindReplicationPositionFromXtrabackupInfo(t *testing.T) {
tmp, err := os.MkdirTemp(t.TempDir(), "test")
assert.NoError(t, err)

f, err := os.Create(path.Join(tmp, "xtrabackup_info"))
f, err := os.Create(path.Join(tmp, xtrabackupInfoFile))
assert.NoError(t, err)
_, err = f.WriteString(input)
assert.NoError(t, err)
Expand Down

0 comments on commit 1a7995a

Please sign in to comment.