зеркало из https://github.com/github/vitess-gh.git
Fix mysql_upgrade during Restore.
1) mysqld needs to be running to use mysql_upgrade. 2) mysql_upgrade needs to be told how to connect to mysqld.
This commit is contained in:
Родитель
a3c11d0f34
Коммит
5e49324680
|
@ -552,12 +552,25 @@ func Restore(ctx context.Context, mysqld MysqlDaemon, bucket string, restoreConc
|
|||
return proto.ReplicationPosition{}, err
|
||||
}
|
||||
|
||||
log.Infof("Restore: running mysql_upgrade if necessary")
|
||||
if err := mysqld.RunMysqlUpgrade(); err != nil {
|
||||
// mysqld needs to be running in order for mysql_upgrade to work.
|
||||
log.Infof("Restore: starting mysqld for mysql_upgrade")
|
||||
err = mysqld.Start(ctx)
|
||||
if err != nil {
|
||||
return proto.ReplicationPosition{}, err
|
||||
}
|
||||
|
||||
log.Infof("Restore: restart mysqld")
|
||||
log.Infof("Restore: running mysql_upgrade")
|
||||
if err := mysqld.RunMysqlUpgrade(); err != nil {
|
||||
return proto.ReplicationPosition{}, fmt.Errorf("mysql_upgrade failed: %v", err)
|
||||
}
|
||||
|
||||
// The MySQL manual recommends restarting mysqld after running mysql_upgrade,
|
||||
// so that any changes made to system tables take effect.
|
||||
log.Infof("Restore: restarting mysqld after mysql_upgrade")
|
||||
err = mysqld.Shutdown(ctx, true)
|
||||
if err != nil {
|
||||
return proto.ReplicationPosition{}, err
|
||||
}
|
||||
err = mysqld.Start(ctx)
|
||||
if err != nil {
|
||||
return proto.ReplicationPosition{}, err
|
||||
|
|
|
@ -143,7 +143,17 @@ func (mysqld *Mysqld) RunMysqlUpgrade() error {
|
|||
}
|
||||
|
||||
// run the program, if it fails, we fail
|
||||
cmd := exec.Command(name, "--defaults-file="+mysqld.config.path)
|
||||
args := []string{
|
||||
// --defaults-file=* must be the first arg.
|
||||
"--defaults-file=" + mysqld.config.path,
|
||||
"--socket", mysqld.config.SocketFile,
|
||||
"--user", mysqld.dba.Uname,
|
||||
}
|
||||
if mysqld.dba.Pass != "" {
|
||||
// --password must be omitted entirely if empty, or else it will prompt.
|
||||
args = append(args, "--password", mysqld.dba.Pass)
|
||||
}
|
||||
cmd := exec.Command(name, args...)
|
||||
cmd.Env = []string{os.ExpandEnv("LD_LIBRARY_PATH=$VT_MYSQL_ROOT/lib/mysql")}
|
||||
stderr, err := cmd.StderrPipe()
|
||||
if err != nil {
|
||||
|
|
Загрузка…
Ссылка в новой задаче