Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat: embed mysql client binary (#1409)

h3n4l03b2584c8cac
diff --git a/plugin/restore/mysql/mysql.go b/plugin/restore/mysql/mysql.go
index e6c6c9109a..4b5025e06d 100644
--- a/plugin/restore/mysql/mysql.go
+++ b/plugin/restore/mysql/mysql.go
@@ -13,7 +13,7 @@ import (
"github.com/blang/semver/v4"
"github.com/bytebase/bytebase/api"
mysql "github.com/bytebase/bytebase/plugin/db/mysql"
- "github.com/bytebase/bytebase/resources/mysqlbinlog"
+ "github.com/bytebase/bytebase/resources/mysqlutil"
)
const (
@@ -28,15 +28,15 @@ const (
// 2. Create a database called `dbfoo_pitr_1653018005_old`, and move tables
// from `dbfoo` to `dbfoo_pitr_1653018005_old`, and tables from `dbfoo_pitr_1653018005` to `dbfoo`.
type Restore struct {
- driver *mysql.Driver
- mysqlbinlog *mysqlbinlog.Instance
+ driver *mysql.Driver
+ mysqlutil *mysqlutil.Instance
}
// New creates a new instance of Restore
-func New(driver *mysql.Driver, instance *mysqlbinlog.Instance) *Restore {
+func New(driver *mysql.Driver, instance *mysqlutil.Instance) *Restore {
return &Restore{
- driver: driver,
- mysqlbinlog: instance,
+ driver: driver,
+ mysqlutil: instance,
}
}
@@ -251,7 +251,7 @@ func (r *Restore) downloadBinlogFile(ctx context.Context, instance *api.Instance
// for mysqlbinlog binary, --result-file must end with '/'
resultFileDir := strings.TrimRight(saveDir, "/") + "/"
// TODO(zp): support ssl?
- cmd := exec.CommandContext(ctx, r.mysqlbinlog.GetPath(),
+ cmd := exec.CommandContext(ctx, r.mysqlutil.GetPath(mysqlutil.MySQL),
binlog.Name,
fmt.Sprintf("--read-from-remote-server --host=%s --port=%s --user=%s --password=%s", instance.Host, instance.Port, instance.Username, instance.Password),
"--raw",
diff --git a/resources/README.md b/resources/README.md
index 6d61f968fc..4ac02a6588 100644
--- a/resources/README.md
+++ b/resources/README.md
@@ -22,12 +22,12 @@ linux-glibc2.17-x86_64 used for Linux (MD5 55a7759e25cc527416150c8181ce3f6d): ht
macos11-arm64 used for MacOS Apple Silicon development (MD5 f1943053b12428e4c0e4ed309a636fd0): https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.28-macos11-arm64.tar.gz
-### mysqlbinlog
+### mysqlutil
-We embed mysqlbinlog for PITR. MySQL does not provide a separate mysqlbinlog binary, and we need to extract our files from the MySQL distribution manually.
+We embed mysqlutil for PITR. MySQL does not provide separate mysql and mysqlbinlog binaries, and we need to extract our files from the MySQL distribution manually.
-linux-glibc2.17-x86_64 used for Linux (MD5 55a7759e25cc527416150c8181ce3f6d): https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.28-linux-glibc2.17-x86_64-minimal.tar.xz, extract bin/mysqlbinlog, lib/private/libcrypto.so.1.1 and lib/private/libssl.so.1.1.
+linux-glibc2.17-x86_64 used for Linux (MD5 55a7759e25cc527416150c8181ce3f6d): https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.28-linux-glibc2.17-x86_64-minimal.tar.xz, extract bin/mysqlbinlog, bin/mysql, lib/private/libcrypto.so.1.1 and lib/private/libssl.so.1.1.
-macos11-arm64 used for MacOS Apple Silicon development (MD5 f1943053b12428e4c0e4ed309a636fd0): https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.28-macos11-arm64.tar.gz, extract bin/mysqlbinlog, lib/libcrypto.1.1.dylib and lib/libssl.1.1.dylib.
+macos11-arm64 used for MacOS Apple Silicon development (MD5 f1943053b12428e4c0e4ed309a636fd0): https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-8.0.28-macos11-arm64.tar.gz, extract bin/mysqlbinlog, bin/mysql, lib/libcrypto.1.1.dylib and lib/libssl.1.1.dylib.
-macos11-x86_64 used for MacOS Intel Silicon development (MD5 b2d5b57edb92811040fd61c84f1c9d6f): https://cdn.mysql.com/archives/mysql-8.0/mysql-8.0.28-macos11-x86_64.tar.gz, extract bin/mysqlbinlog, lib/libcrypto.1.1.dylib and lib/libssl.1.1.dylib.
+macos11-x86_64 used for MacOS Intel Silicon development (MD5 b2d5b57edb92811040fd61c84f1c9d6f): https://cdn.mysql.com/archives/mysql-8.0/mysql-8.0.28-macos11-x86_64.tar.gz, extract bin/mysqlbinlog, bin/mysql, lib/libcrypto.1.1.dylib and lib/libssl.1.1.dylib.
diff --git a/resources/mysqlbinlog/mysqlbinlog.go b/resources/mysqlbinlog/mysqlbinlog.go
deleted file mode 100644
index abc14f04ab..0000000000
--- a/resources/mysqlbinlog/mysqlbinlog.go
+++ /dev/null
@@ -1,84 +0,0 @@
-package mysqlbinlog
-
-import (
- "bytes"
- "fmt"
- "os"
- "os/exec"
- "path"
- "path/filepath"
- "runtime"
- "strings"
-
- "github.com/bytebase/bytebase/resources/utils"
-)
-
-// Instance involve the path of mysqlbinlog binary.
-type Instance struct {
- binPath string
-}
-
-// GetPath returns the mysqlbinlog binary path.
-func (ins *Instance) GetPath() string {
- return ins.binPath
-}
-
-// Version returns the raw output of `mysqlbinlog -V`
-func (ins *Instance) Version() (string, error) {
- var version bytes.Buffer
-
- cmd := exec.Command(ins.GetPath(), "-V")
- cmd.Stdout = &version
- cmd.Stderr = os.Stderr
-
- if err := cmd.Run(); err != nil {
- return "", err
- }
-
- return version.String(), nil
-}
-
-// Install will extract the mysqlbinlog tar in resourceDir.
-func Install(resourceDir string) (*Instance, error) {
- var tarName string
- switch {
- case runtime.GOOS == "darwin" && runtime.GOARCH == "arm64":
- tarName = "mysqlbinlog-8.0.28-macos11-arm64.tar.gz"
- case runtime.GOOS == "darwin" && runtime.GOARCH == "amd64":
- tarName = "mysqlbinlog-8.0.28-macos11-x86_64.tar.gz"
- case runtime.GOOS == "linux" && runtime.GOARCH == "amd64":
- tarName = "mysqlbinlog-8.0.28-linux-glibc-2.17-x86_64.tar.gz"
- default:
- return nil, fmt.Errorf("Unsupported combination of OS[%s] and ARCH[%s]", runtime.GOOS, runtime.GOARCH)
- }
-
- version := strings.TrimRight(tarName, "tar.gz")
- mysqlbinlogDir := path.Join(resourceDir, version)
- if _, err := os.Stat(mysqlbinlogDir); err != nil {
- if !os.IsNotExist(err) {
- return nil, fmt.Errorf("failed to check binary directory path %q, error: %w", mysqlbinlogDir, err)
- }
- // Install if not exist yet
- tmpDir := path.Join(resourceDir, fmt.Sprintf("tmp-%s", version))
- if err := os.RemoveAll(tmpDir); err != nil {
- return nil, fmt.Errorf("failed to remove mysqlbinlog binary temp directory %q, error: %w", tmpDir, err)
- }
-
- f, err := resources.Open(tarName)
- if err != nil {
- return nil, fmt.Errorf("failed to find %q in embedded resources, error: %v", tarName, err)
- }
- defer f.Close()
-
- if err := utils.ExtractTarGz(f, tmpDir); err != nil {
- return nil, fmt.Errorf("failed to extract tar.gz file, error: %w", err)
- }
-
- if err := os.Rename(tmpDir, mysqlbinlogDir); err != nil {
- return nil, fmt.Errorf("failed to rename mysqlbinlog binary directory from %q to %q, error: %w", tmpDir, mysqlbinlogDir, err)
- }
- }
- return &Instance{
- binPath: filepath.Join(mysqlbinlogDir, version, "bin", "mysqlbinlog"),
- }, nil
-}
diff --git a/resources/mysqlbinlog/mysqlbinlog_test.go b/resources/mysqlbinlog/mysqlbinlog_test.go
deleted file mode 100644
index be3c87be8f..0000000000
--- a/resources/mysqlbinlog/mysqlbinlog_test.go
+++ /dev/null
@@ -1,19 +0,0 @@
-package mysqlbinlog
-
-import (
- "testing"
-
- "github.com/stretchr/testify/require"
-)
-
-// TestRunBinary tests whether mysqlbinlog can be started on the target platform
-// to check whether the lib extraction is correct.
-func TestRunBinary(t *testing.T) {
- a := require.New(t)
- tmpDir := t.TempDir()
- ins, err := Install(tmpDir)
- a.NoError(err)
-
- _, err = ins.Version()
- a.NoError(err)
-}
diff --git a/resources/mysqlutil/mysqlutil.go b/resources/mysqlutil/mysqlutil.go
new file mode 100644
index 0000000000..dab0bf922f
--- /dev/null
+++ b/resources/mysqlutil/mysqlutil.go
@@ -0,0 +1,107 @@
+package mysqlutil
+
+import (
+ "bytes"
+ "fmt"
+ "os"
+ "os/exec"
+ "path"
+ "path/filepath"
+ "runtime"
+ "strings"
+
+ "github.com/bytebase/bytebase/resources/utils"
+)
+
+type binaryName string
+
+const (
+ // MySQL is the name of mysql binary
+ MySQL binaryName = "mysql"
+ // MySQLBinlog is the name of mysqlbinlog binary
+ MySQLBinlog binaryName = "mysqlbinlog"
+)
+
+// Instance involve the path of all binaries binary.
+type Instance struct {
+ mysqlBinPath string
+ mysqlbinlogBinPath string
+}
+
+// GetPath returns the binary path specified by `binName`.
+func (ins *Instance) GetPath(binName binaryName) string {
+ switch binName {
+ case MySQL:
+ return ins.mysqlBinPath
+ case MySQLBinlog:
+ return ins.mysqlbinlogBinPath
+ }
+ return "UNKNOWN"
+}
+
+// Version returns the raw output of ``binName` -V`.
+func (ins *Instance) Version(binName binaryName) (string, error) {
+ var cmd *exec.Cmd
+ var version bytes.Buffer
+ switch binName {
+ case MySQL:
+ cmd = exec.Command(ins.GetPath(MySQL), "-V")
+ case MySQLBinlog:
+ cmd = exec.Command(ins.GetPath(MySQLBinlog), "-V")
+ default:
+ return "", fmt.Errorf("Unknown binary name: %s", binName)
+ }
+
+ cmd.Stdout = &version
+ cmd.Stderr = os.Stderr
+ if err := cmd.Run(); err != nil {
+ return "", err
+ }
+ return version.String(), nil
+}
+
+// Install will extract the mysqlutil tar in resourceDir.
+func Install(resourceDir string) (*Instance, error) {
+ var tarName string
+ switch {
+ case runtime.GOOS == "darwin" && runtime.GOARCH == "arm64":
+ tarName = "mysqlutil-8.0.28-macos11-arm64.tar.gz"
+ case runtime.GOOS == "darwin" && runtime.GOARCH == "amd64":
+ tarName = "mysqlutil-8.0.28-macos11-x86_64.tar.gz"
+ case runtime.GOOS == "linux" && runtime.GOARCH == "amd64":
+ tarName = "mysqlutil-8.0.28-linux-glibc2.17-x86_64.tar.gz"
+ default:
+ return nil, fmt.Errorf("Unsupported combination of OS[%s] and ARCH[%s]", runtime.GOOS, runtime.GOARCH)
+ }
+
+ version := strings.TrimRight(tarName, "tar.gz")
+ mysqlutilDir := path.Join(resourceDir, version)
+ if _, err := os.Stat(mysqlutilDir); err != nil {
+ if !os.IsNotExist(err) {
+ return nil, fmt.Errorf("failed to check binary directory path %q, error: %w", mysqlutilDir, err)
+ }
+ // Install if not exist yet
+ tmpDir := path.Join(resourceDir, fmt.Sprintf("tmp-%s", version))
+ if err := os.RemoveAll(tmpDir); err != nil {
+ return nil, fmt.Errorf("failed to remove mysqlutil binaries temp directory %q, error: %w", tmpDir, err)
+ }
+
+ f, err := resources.Open(tarName)
+ if err != nil {
+ return nil, fmt.Errorf("failed to find %q in embedded resources, error: %v", tarName, err)
+ }
+ defer f.Close()
+
+ if err := utils.ExtractTarGz(f, tmpDir); err != nil {
+ return nil, fmt.Errorf("failed to extract tar.gz file, error: %w", err)
+ }
+
+ if err := os.Rename(tmpDir, mysqlutilDir); err != nil {
+ return nil, fmt.Errorf("failed to rename mysqlutil binaries directory from %q to %q, error: %w", tmpDir, mysqlutilDir, err)
+ }
+ }
+ return &Instance{
+ mysqlBinPath: filepath.Join(mysqlutilDir, "bin", "mysql"),
+ mysqlbinlogBinPath: filepath.Join(mysqlutilDir, "bin", "mysqlbinlog"),
+ }, nil
+}
diff --git a/resources/mysqlutil/mysqlutil_test.go b/resources/mysqlutil/mysqlutil_test.go
new file mode 100644
index 0000000000..4517fb27b9
--- /dev/null
+++ b/resources/mysqlutil/mysqlutil_test.go
@@ -0,0 +1,28 @@
+package mysqlutil
+
+import (
+ "testing"
+
+ "github.com/stretchr/testify/require"
+)
+
+// TestRunBinary tests whether all binarys can be started on the target platform
+// to check whether the lib extraction is correct.
+func TestRunBinary(t *testing.T) {
+ t.Parallel()
+
+ a := require.New(t)
+ tmpDir := t.TempDir()
+ ins, err := Install(tmpDir)
+ a.NoError(err)
+
+ t.Run("run mysql client", func(t *testing.T) {
+ _, err := ins.Version(MySQL)
+ a.NoError(err)
+ })
+
+ t.Run("run mysqlbinlog", func(t *testing.T) {
+ _, err := ins.Version(MySQLBinlog)
+ a.NoError(err)
+ })
+}
diff --git a/resources/mysqlbinlog/resources_darwin_amd64.go b/resources/mysqlutil/resources_darwin_amd64.go
similarity index 55%
rename from resources/mysqlbinlog/resources_darwin_amd64.go
rename to resources/mysqlutil/resources_darwin_amd64.go
index 21413d00ec..771a4717a8 100644
--- a/resources/mysqlbinlog/resources_darwin_amd64.go
+++ b/resources/mysqlutil/resources_darwin_amd64.go
@@ -1,9 +1,9 @@
//go:build darwin && amd64
// +build darwin,amd64
-package mysqlbinlog
+package mysqlutil
import "embed"
-//go:embed mysqlbinlog-8.0.28-macos11-x86_64.tar.gz
+//go:embed mysqlutil-8.0.28-macos11-x86_64.tar.gz
var resources embed.FS
diff --git a/resources/mysqlbinlog/resources_darwin_arm64.go b/resources/mysqlutil/resources_darwin_arm64.go
similarity index 56%
rename from resources/mysqlbinlog/resources_darwin_arm64.go
rename to resources/mysqlutil/resources_darwin_arm64.go
index 1a0385ba57..ef7e971d02 100644
--- a/resources/mysqlbinlog/resources_darwin_arm64.go
+++ b/resources/mysqlutil/resources_darwin_arm64.go
@@ -1,9 +1,9 @@
//go:build darwin && arm64
// +build darwin,arm64
-package mysqlbinlog
+package mysqlutil
import "embed"
-//go:embed mysqlbinlog-8.0.28-macos11-arm64.tar.gz
+//go:embed mysqlutil-8.0.28-macos11-arm64.tar.gz
var resources embed.FS
diff --git a/resources/mysqlbinlog/resources_linux_arm64.go b/resources/mysqlutil/resources_linux_arm64.go
similarity index 59%
rename from resources/mysqlbinlog/resources_linux_arm64.go
rename to resources/mysqlutil/resources_linux_arm64.go
index 5027358ab3..c55597032b 100644
--- a/resources/mysqlbinlog/resources_linux_arm64.go
+++ b/resources/mysqlutil/resources_linux_arm64.go
@@ -1,10 +1,10 @@
//go:build linux && arm64
// +build linux,arm64
-package mysqlbinlog
+package mysqlutil
import "embed"
//TODO(zp): need test for arm64
-//go:embed mysqlbinlog-8.0.28-linux-glibc-2.17-x86_64.tar.gz
+//go:embed mysqlutil-8.0.28-linux-glibc2.17-x86_64.tar.gz
var resources embed.FS
diff --git a/resources/mysqlbinlog/resources_linux_x86_64.go b/resources/mysqlutil/resources_linux_x86_64.go
similarity index 52%
rename from resources/mysqlbinlog/resources_linux_x86_64.go
rename to resources/mysqlutil/resources_linux_x86_64.go
index 30c4b4e4b5..57f504be24 100644
--- a/resources/mysqlbinlog/resources_linux_x86_64.go
+++ b/resources/mysqlutil/resources_linux_x86_64.go
@@ -1,9 +1,9 @@
//go:build linux && amd64
// +build linux,amd64
-package mysqlbinlog
+package mysqlutil
import "embed"
-//go:embed mysqlbinlog-8.0.28-linux-glibc-2.17-x86_64.tar.gz
+//go:embed mysqlutil-8.0.28-linux-glibc2.17-x86_64.tar.gz
var resources embed.FS
diff --git a/server/server.go b/server/server.go
index c45d3cfb19..06229ba3f4 100644
--- a/server/server.go
+++ b/server/server.go
@@ -26,7 +26,7 @@ import (
enterpriseService "github.com/bytebase/bytebase/enterprise/service"
"github.com/bytebase/bytebase/metric"
metricCollector "github.com/bytebase/bytebase/metric/collector"
- "github.com/bytebase/bytebase/resources/mysqlbinlog"
+ "github.com/bytebase/bytebase/resources/mysqlutil"
"github.com/bytebase/bytebase/store"
)
@@ -46,16 +46,16 @@ type Server struct {
LicenseService enterpriseAPI.LicenseService
subscription enterpriseAPI.Subscription
- profile Profile
- e *echo.Echo
- mysqlbinlog *mysqlbinlog.Instance
- metaDB *store.MetadataDB
- db *store.DB
- store *store.Store
- l *zap.Logger
- lvl *zap.AtomicLevel
- startedTs int64
- secret string
+ profile Profile
+ e *echo.Echo
+ mysqlutil *mysqlutil.Instance
+ metaDB *store.MetadataDB
+ db *store.DB
+ store *store.Store
+ l *zap.Logger
+ lvl *zap.AtomicLevel
+ startedTs int64
+ secret string
// boot specifies that whether the server boot correctly
cancel context.CancelFunc
@@ -105,12 +105,12 @@ func NewServer(ctx context.Context, prof Profile, logger *zap.Logger, loggerLeve
var err error
resourceDir := common.GetResourceDir(prof.DataDir)
- // Install mysqlbinlog.
- mysqlbinlogIns, err := mysqlbinlog.Install(resourceDir)
+ // Install mysqlutil
+ mysqlutilIns, err := mysqlutil.Install(resourceDir)
if err != nil {
return nil, fmt.Errorf("cannot install mysqlbinlog binary, error: %w", err)
}
- s.mysqlbinlog = mysqlbinlogIns
+ s.mysqlutil = mysqlutilIns
// New MetadataDB instance.
if prof.useEmbedDB() {
@@ -189,10 +189,10 @@ func NewServer(ctx context.Context, prof Profile, logger *zap.Logger, loggerLeve
schemaUpdateGhostDropOriginalTableExecutor := NewSchemaUpdateGhostDropOriginalTableTaskExecutor(logger)
taskScheduler.Register(string(api.TaskDatabaseSchemaUpdateGhostDropOriginalTable), schemaUpdateGhostDropOriginalTableExecutor)
- pitrRestoreExecutor := NewPITRRestoreTaskExecutor(logger, s.mysqlbinlog)
+ pitrRestoreExecutor := NewPITRRestoreTaskExecutor(logger, s.mysqlutil)
taskScheduler.Register(string(api.TaskDatabasePITRRestore), pitrRestoreExecutor)
- pitrCutoverExecutor := NewPITRCutoverTaskExecutor(logger, s.mysqlbinlog)
+ pitrCutoverExecutor := NewPITRCutoverTaskExecutor(logger, s.mysqlutil)
taskScheduler.Register(string(api.TaskDatabasePITRCutover), pitrCutoverExecutor)
s.TaskScheduler = taskScheduler
diff --git a/server/task_executor_pitr_cutover.go b/server/task_executor_pitr_cutover.go
index 6fcea97324..1870034e26 100644
--- a/server/task_executor_pitr_cutover.go
+++ b/server/task_executor_pitr_cutover.go
@@ -7,22 +7,22 @@ import (
"github.com/bytebase/bytebase/api"
pluginmysql "github.com/bytebase/bytebase/plugin/db/mysql"
restoremysql "github.com/bytebase/bytebase/plugin/restore/mysql"
- "github.com/bytebase/bytebase/resources/mysqlbinlog"
+ "github.com/bytebase/bytebase/resources/mysqlutil"
"go.uber.org/zap"
)
// NewPITRCutoverTaskExecutor creates a PITR cutover task executor.
-func NewPITRCutoverTaskExecutor(logger *zap.Logger, instance *mysqlbinlog.Instance) TaskExecutor {
+func NewPITRCutoverTaskExecutor(logger *zap.Logger, instance *mysqlutil.Instance) TaskExecutor {
return &PITRCutoverTaskExecutor{
- l: logger,
- mysqlbinlog: instance,
+ l: logger,
+ mysqlutil: instance,
}
}
// PITRCutoverTaskExecutor is the PITR cutover task executor.
type PITRCutoverTaskExecutor struct {
- l *zap.Logger
- mysqlbinlog *mysqlbinlog.Instance
+ l *zap.Logger
+ mysqlutil *mysqlutil.Instance
}
// RunOnce will run the PITR cutover task executor once.
@@ -51,7 +51,7 @@ func (exec *PITRCutoverTaskExecutor) pitrCutover(ctx context.Context, task *api.
exec.l.Error("failed to cast driver to mysql.Driver", zap.Stack("stack"))
return true, nil, fmt.Errorf("[internal] cast driver to mysql.Driver failed")
}
- mysqlRestore := restoremysql.New(mysqlDriver, exec.mysqlbinlog)
+ mysqlRestore := restoremysql.New(mysqlDriver, exec.mysqlutil)
exec.l.Info("Start swapping the original and PITR database",
zap.String("instance", task.Instance.Name),
diff --git a/server/task_executor_pitr_restore.go b/server/task_executor_pitr_restore.go
index d2c0c25553..b494bf4d5a 100644
--- a/server/task_executor_pitr_restore.go
+++ b/server/task_executor_pitr_restore.go
@@ -11,23 +11,23 @@ import (
"github.com/bytebase/bytebase/plugin/db"
pluginmysql "github.com/bytebase/bytebase/plugin/db/mysql"
restoremysql "github.com/bytebase/bytebase/plugin/restore/mysql"
- "github.com/bytebase/bytebase/resources/mysqlbinlog"
+ "github.com/bytebase/bytebase/resources/mysqlutil"
"github.com/bytebase/bytebase/store"
"go.uber.org/zap"
)
// NewPITRRestoreTaskExecutor creates a PITR restore task executor.
-func NewPITRRestoreTaskExecutor(logger *zap.Logger, instance *mysqlbinlog.Instance) TaskExecutor {
+func NewPITRRestoreTaskExecutor(logger *zap.Logger, instance *mysqlutil.Instance) TaskExecutor {
return &PITRRestoreTaskExecutor{
- l: logger,
- mysqlbinlog: instance,
+ l: logger,
+ mysqlutil: instance,
}
}
// PITRRestoreTaskExecutor is the PITR restore task executor.
type PITRRestoreTaskExecutor struct {
- l *zap.Logger
- mysqlbinlog *mysqlbinlog.Instance
+ l *zap.Logger
+ mysqlutil *mysqlutil.Instance
}
// RunOnce will run the PITR restore task executor once.
@@ -77,7 +77,7 @@ func (exec *PITRRestoreTaskExecutor) doPITRRestore(ctx context.Context, task *ap
return fmt.Errorf("[internal] cast driver to mysql.Driver failed")
}
- mysqlRestore := restoremysql.New(mysqlDriver, exec.mysqlbinlog)
+ mysqlRestore := restoremysql.New(mysqlDriver, exec.mysqlutil)
config := pluginmysql.BinlogInfo{}
// TODO(dragonly): Search and put the file io of the logical backup file here.
// Currently, let's just use the empty backup dump as a placeholder.
diff --git a/tests/backup_restore_test.go b/tests/backup_restore_test.go
index e0224db23f..b73ceaaf07 100644
--- a/tests/backup_restore_test.go
+++ b/tests/backup_restore_test.go
@@ -17,7 +17,7 @@ import (
pluginmysql "github.com/bytebase/bytebase/plugin/db/mysql"
restoremysql "github.com/bytebase/bytebase/plugin/restore/mysql"
resourcemysql "github.com/bytebase/bytebase/resources/mysql"
- "github.com/bytebase/bytebase/resources/mysqlbinlog"
+ "github.com/bytebase/bytebase/resources/mysqlutil"
"github.com/stretchr/testify/require"
)
@@ -123,7 +123,7 @@ func TestPITR(t *testing.T) {
t.Log("install mysqlbinlog binary")
tmpDir := t.TempDir()
- mysqlbinlogIns, err := mysqlbinlog.Install(tmpDir)
+ mysqlbinlogIns, err := mysqlutil.Install(tmpDir)
a.NoError(err)
// test cases
diff --git a/tests/mysql_test.go b/tests/mysql_test.go
index 3e55011f4a..6f8da1a93b 100644
--- a/tests/mysql_test.go
+++ b/tests/mysql_test.go
@@ -9,7 +9,7 @@ import (
pluginmysql "github.com/bytebase/bytebase/plugin/db/mysql"
restoremysql "github.com/bytebase/bytebase/plugin/restore/mysql"
resourcemysql "github.com/bytebase/bytebase/resources/mysql"
- "github.com/bytebase/bytebase/resources/mysqlbinlog"
+ "github.com/bytebase/bytebase/resources/mysqlutil"
"github.com/stretchr/testify/require"
)
@@ -22,7 +22,7 @@ func TestCheckEngineInnoDB(t *testing.T) {
t.Log("install mysqlbinlog binary")
tmpDir := t.TempDir()
- mysqlbinlogIns, err := mysqlbinlog.Install(tmpDir)
+ mysqlbinlogIns, err := mysqlutil.Install(tmpDir)
a.NoError(err)
t.Run("success", func(t *testing.T) {