From b6f0acf36438da16c5562d53c7b1d8f99ec23887 Mon Sep 17 00:00:00 2001 From: Jacques Grove Date: Mon, 15 Nov 2021 15:14:12 -0800 Subject: [PATCH 1/2] Set super_read_only off during restore; achieves same as PR #8929 Signed-off-by: Jacques Grove --- go/vt/mysqlctl/backup.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/go/vt/mysqlctl/backup.go b/go/vt/mysqlctl/backup.go index 8480c4615ec..a638c09229a 100644 --- a/go/vt/mysqlctl/backup.go +++ b/go/vt/mysqlctl/backup.go @@ -334,6 +334,16 @@ 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 { + params.Logger.Warningf("Restore: setting super_read_only failed, continuing anyway: %v", err) + } + params.Logger.Infof("Restore: running mysql_upgrade") if err := params.Mysqld.RunMysqlUpgrade(); err != nil { return nil, vterrors.Wrap(err, "mysql_upgrade failed") From e4c2f7dacb6ce271285ce82d30c51e09910d150f Mon Sep 17 00:00:00 2001 From: Jacques Grove Date: Mon, 22 Nov 2021 12:43:14 -0800 Subject: [PATCH 2/2] Better error handling for the MariaDB case where setting super_read_only will fail. Signed-off-by: Jacques Grove --- go/vt/mysqlctl/backup.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/go/vt/mysqlctl/backup.go b/go/vt/mysqlctl/backup.go index a638c09229a..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 ( @@ -341,7 +343,12 @@ func Restore(ctx context.Context, params RestoreParams) (*BackupManifest, error) // 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 { - params.Logger.Warningf("Restore: setting super_read_only failed, continuing anyway: %v", err) + 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")