diff --git a/go/vt/mysqlctl/backup.go b/go/vt/mysqlctl/backup.go index 8480c4615ec..d5b6c7681e7 100644 --- a/go/vt/mysqlctl/backup.go +++ b/go/vt/mysqlctl/backup.go @@ -58,6 +58,8 @@ const ( const ( // replicationStartDeadline is the deadline for starting replication replicationStartDeadline = 30 + + Error1193 = "Unknown system variable" ) var ( @@ -334,6 +336,21 @@ func Restore(ctx context.Context, params RestoreParams) (*BackupManifest, error) return nil, err } + // We disable super_read_only, in case it is in the default MySQL startup + // parameters and will be blocking the writes we need to do in + // PopulateMetadataTables(). We do it blindly, since + // this will fail on MariaDB, which doesn't have super_read_only + // This is safe, since we're restarting MySQL after the restore anyway + params.Logger.Infof("Restore: disabling super_read_only") + if err := params.Mysqld.SetSuperReadOnly(false); err != nil { + if strings.Contains(err.Error(), Error1193) { + params.Logger.Warningf("Restore: server does not know about super_read_only; maybe MariaDB? Continuing anyway.") + } else { + params.Logger.Errorf("Restore: unexpected error while trying to set super_read_only: %v", err) + return nil, err + } + } + params.Logger.Infof("Restore: running mysql_upgrade") if err := params.Mysqld.RunMysqlUpgrade(); err != nil { return nil, vterrors.Wrap(err, "mysql_upgrade failed")