Skip to content

Commit 8bd3fbe

Browse files
authored
fix version issue when using --mysql-shell-speedup-restore=true (#18310)
1 parent 42317c0 commit 8bd3fbe

File tree

3 files changed

+52
-11
lines changed

3 files changed

+52
-11
lines changed

go/test/endtoend/backup/vtctlbackup/backup_utils.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ func LaunchCluster(setupType int, streamMode string, stripes int, cDetails *Comp
167167
mysqlShellArgs := []string{
168168
vtutils.GetFlagVariantForTests("--backup-engine-implementation"), "mysqlshell",
169169
"--mysql-shell-backup-location", mysqlShellBackupLocation,
170+
"--mysql-shell-speedup-restore=true",
170171
}
171172
commonTabletArg = append(commonTabletArg, mysqlShellArgs...)
172173
}

go/vt/mysqlctl/mysqlshellbackupengine.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,14 +458,21 @@ func (be *MySQLShellBackupEngine) restorePreCheck(ctx context.Context, params Re
458458
return false, fmt.Errorf("%w: failed to fetch MySQL version: %v", ErrMySQLShellPreCheck, err)
459459
}
460460

461-
capableOf := mysql.ServerVersionCapableOf(version)
461+
_, sv, err := ParseVersionString(version)
462+
if err != nil {
463+
return false, fmt.Errorf("%w: failed to parse MySQL version (version: %s): %v", ErrMySQLShellPreCheck, version, err)
464+
}
465+
466+
versionStr := fmt.Sprintf("%d.%d.%d", sv.Major, sv.Minor, sv.Patch)
467+
468+
capableOf := mysql.ServerVersionCapableOf(versionStr)
462469
capable, err := capableOf(capabilities.DisableRedoLogFlavorCapability)
463470
if err != nil {
464471
return false, fmt.Errorf("%w: error checking if server supports disabling redo log: %v", ErrMySQLShellPreCheck, err)
465472
}
466473

467474
if !capable {
468-
return false, fmt.Errorf("%w: MySQL version doesn't support disabling the redo log (must be >=8.0.21)", ErrMySQLShellPreCheck)
475+
return false, fmt.Errorf("%w: MySQL version doesn't support disabling the redo log (must be >=8.0.21, current version: %s)", ErrMySQLShellPreCheck, versionStr)
469476
}
470477
}
471478

go/vt/mysqlctl/mysqlshellbackupengine_test.go

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,25 +159,58 @@ func TestMySQLShellBackupRestorePreCheckDisableRedolog(t *testing.T) {
159159
mysqlShellSpeedUpRestore = true
160160
engine := MySQLShellBackupEngine{}
161161

162+
tests := []struct {
163+
version string
164+
err error
165+
}{
166+
{
167+
version: "mysqld Ver 5.7.27-0ubuntu0.19.04.1 for Linux on x86_64 ((Ubuntu))",
168+
err: ErrMySQLShellPreCheck,
169+
},
170+
{
171+
version: "mysqld Ver 5.7.26 for linux-glibc2.12 on x86_64 (MySQL Community Server (GPL))",
172+
err: ErrMySQLShellPreCheck,
173+
},
174+
{
175+
version: "mysqld Ver 5.7.26-29 for Linux on x86_64 (Percona Server (GPL), Release 29, Revision 11ad961)",
176+
err: ErrMySQLShellPreCheck,
177+
},
178+
{
179+
version: "mysqld Ver 8.0.16 for linux-glibc2.12 on x86_64 (MySQL Community Server - GPL)",
180+
err: ErrMySQLShellPreCheck,
181+
},
182+
{
183+
version: "mysqld Ver 8.0.15-6 for Linux on x86_64 (Percona Server (GPL), Release 6, Revision 63abd08)",
184+
err: ErrMySQLShellPreCheck,
185+
},
186+
{
187+
version: "mysqld Ver 8.0.42-0ubuntu0.22.04.1 for Linux on x86_64 ((Ubuntu))",
188+
err: nil,
189+
},
190+
{
191+
version: "mysqld Ver 8.0.42-33 for Linux on x86_64 (Percona Server (GPL), Release '33', Revision '9dc49998')",
192+
err: nil,
193+
},
194+
}
195+
162196
fakedb := fakesqldb.New(t)
163197
defer fakedb.Close()
164-
fakeMysqld := NewFakeMysqlDaemon(fakedb) // defaults to 8.0.32
198+
fakeMysqld := NewFakeMysqlDaemon(fakedb)
165199
defer fakeMysqld.Close()
166200

167201
params := RestoreParams{
168202
Mysqld: fakeMysqld,
169203
}
170204

171-
// this should work as it is supported since 8.0.21
172-
_, err := engine.restorePreCheck(context.Background(), params)
173-
require.NoError(t, err, params)
205+
for _, tt := range tests {
206+
t.Run(tt.version, func(t *testing.T) {
207+
fakeMysqld.Version = tt.version
174208

175-
// it should error out if we change to an older version
176-
fakeMysqld.Version = "8.0.20"
209+
_, err := engine.restorePreCheck(context.Background(), params)
210+
require.ErrorIs(t, err, tt.err)
211+
})
212+
}
177213

178-
_, err = engine.restorePreCheck(context.Background(), params)
179-
require.ErrorIs(t, err, ErrMySQLShellPreCheck)
180-
require.ErrorContains(t, err, "doesn't support disabling the redo log")
181214
}
182215

183216
func TestShouldDrainForBackupMySQLShell(t *testing.T) {

0 commit comments

Comments
 (0)