From 8626a36ac9c4aaebbb842824865b544bf58cbdf7 Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Thu, 24 Oct 2024 19:34:23 -0400 Subject: [PATCH] Relax commit order preservation during restore Signed-off-by: Matt Lord --- go/vt/mysqlctl/mycnf.go | 11 +++++++++++ go/vt/vttablet/tabletmanager/restore.go | 11 ++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/go/vt/mysqlctl/mycnf.go b/go/vt/mysqlctl/mycnf.go index c4ee062348b..07019fe446c 100644 --- a/go/vt/mysqlctl/mycnf.go +++ b/go/vt/mysqlctl/mycnf.go @@ -244,3 +244,14 @@ func ReadMycnf(mycnf *Mycnf, waitTime time.Duration) (*Mycnf, error) { return mycnf, nil } + +// SetServerParam can be used *after* ReadMycnf() is called to +// customize the base configuration in the file with additional +// settings that are applicable to a specific scenario such as +// doing a backup restore. +// This is NOT concurrent safe with, together with ReadMycnf() or +// alone. +func (cnf *Mycnf) SetServerParam(key, val string) { + key = normKey([]byte(key)) + cnf.mycnfMap[key] = val +} diff --git a/go/vt/vttablet/tabletmanager/restore.go b/go/vt/vttablet/tabletmanager/restore.go index 35587124108..25e46a29f74 100644 --- a/go/vt/vttablet/tabletmanager/restore.go +++ b/go/vt/vttablet/tabletmanager/restore.go @@ -218,8 +218,17 @@ func (tm *TabletManager) restoreDataLocked(ctx context.Context, logger logutil.L startTime = protoutil.TimeFromProto(keyspaceInfo.SnapshotTime).UTC() } + // Customize our base config specifically for backup restores. + backupCnf := *tm.Cnf + // We only care that we are eventually consistent when the restore + // process ends, we do not care about intermediate states as the + // tablet is not serving during the restore process. + backupCnf.SetServerParam("replica_preserve_commit_order", "OFF") + backupCnf.SetServerParam("sync_relay_log", "0") + backupCnf.SetServerParam("relay_log_recovery", "ON") + params := mysqlctl.RestoreParams{ - Cnf: tm.Cnf, + Cnf: &backupCnf, Mysqld: tm.MysqlDaemon, Logger: logger, Concurrency: restoreConcurrency,