Skip to content

Commit 123e309

Browse files
authored
Allow for specifying a specific MySQL shutdown timeout (vitessio#17923)
Signed-off-by: Dirkjan Bussink <[email protected]>
1 parent ff80a37 commit 123e309

File tree

16 files changed

+1374
-969
lines changed

16 files changed

+1374
-969
lines changed

go/cmd/vtctldclient/command/backups.go

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,12 @@ If no replica-type tablet can be found, the backup can be taken on the primary i
7979
)
8080

8181
var backupOptions = struct {
82-
AllowPrimary bool
83-
BackupEngine string
84-
Concurrency int32
85-
IncrementalFromPos string
86-
UpgradeSafe bool
82+
AllowPrimary bool
83+
BackupEngine string
84+
Concurrency int32
85+
IncrementalFromPos string
86+
UpgradeSafe bool
87+
MysqlShutdownTimeout time.Duration
8788
}{}
8889

8990
func commandBackup(cmd *cobra.Command, args []string) error {
@@ -95,11 +96,12 @@ func commandBackup(cmd *cobra.Command, args []string) error {
9596
cli.FinishedParsing(cmd)
9697

9798
req := &vtctldatapb.BackupRequest{
98-
TabletAlias: tabletAlias,
99-
AllowPrimary: backupOptions.AllowPrimary,
100-
Concurrency: backupOptions.Concurrency,
101-
IncrementalFromPos: backupOptions.IncrementalFromPos,
102-
UpgradeSafe: backupOptions.UpgradeSafe,
99+
TabletAlias: tabletAlias,
100+
AllowPrimary: backupOptions.AllowPrimary,
101+
Concurrency: backupOptions.Concurrency,
102+
IncrementalFromPos: backupOptions.IncrementalFromPos,
103+
UpgradeSafe: backupOptions.UpgradeSafe,
104+
MysqlShutdownTimeout: protoutil.DurationToProto(backupOptions.MysqlShutdownTimeout),
103105
}
104106

105107
if backupOptions.BackupEngine != "" {
@@ -125,10 +127,11 @@ func commandBackup(cmd *cobra.Command, args []string) error {
125127
}
126128

127129
var backupShardOptions = struct {
128-
AllowPrimary bool
129-
Concurrency int32
130-
IncrementalFromPos string
131-
UpgradeSafe bool
130+
AllowPrimary bool
131+
Concurrency int32
132+
IncrementalFromPos string
133+
UpgradeSafe bool
134+
MysqlShutdownTimeout time.Duration
132135
}{}
133136

134137
func commandBackupShard(cmd *cobra.Command, args []string) error {
@@ -140,12 +143,13 @@ func commandBackupShard(cmd *cobra.Command, args []string) error {
140143
cli.FinishedParsing(cmd)
141144

142145
stream, err := client.BackupShard(commandCtx, &vtctldatapb.BackupShardRequest{
143-
Keyspace: keyspace,
144-
Shard: shard,
145-
AllowPrimary: backupShardOptions.AllowPrimary,
146-
Concurrency: backupShardOptions.Concurrency,
147-
IncrementalFromPos: backupShardOptions.IncrementalFromPos,
148-
UpgradeSafe: backupShardOptions.UpgradeSafe,
146+
Keyspace: keyspace,
147+
Shard: shard,
148+
AllowPrimary: backupShardOptions.AllowPrimary,
149+
Concurrency: backupShardOptions.Concurrency,
150+
IncrementalFromPos: backupShardOptions.IncrementalFromPos,
151+
UpgradeSafe: backupShardOptions.UpgradeSafe,
152+
MysqlShutdownTimeout: protoutil.DurationToProto(backupShardOptions.MysqlShutdownTimeout),
149153
})
150154
if err != nil {
151155
return err
@@ -294,12 +298,14 @@ func init() {
294298
Backup.Flags().StringVar(&backupOptions.BackupEngine, "backup-engine", "", "Request a specific backup engine for this backup request. Defaults to the preferred backup engine of the target vttablet")
295299

296300
Backup.Flags().BoolVar(&backupOptions.UpgradeSafe, "upgrade-safe", false, "Whether to use innodb_fast_shutdown=0 for the backup so it is safe to use for MySQL upgrades.")
301+
Backup.Flags().DurationVar(&backupOptions.MysqlShutdownTimeout, "mysql-shutdown-timeout", mysqlctl.DefaultShutdownTimeout, "Timeout to use when MySQL is being shut down.")
297302
Root.AddCommand(Backup)
298303

299304
BackupShard.Flags().BoolVar(&backupShardOptions.AllowPrimary, "allow-primary", false, "Allow the primary of a shard to be used for the backup. WARNING: If using the builtin backup engine, this will shutdown mysqld on the primary and stop writes for the duration of the backup.")
300305
BackupShard.Flags().Int32Var(&backupShardOptions.Concurrency, "concurrency", 4, "Specifies the number of compression/checksum jobs to run simultaneously.")
301306
BackupShard.Flags().StringVar(&backupShardOptions.IncrementalFromPos, "incremental-from-pos", "", "Position, or name of backup from which to create an incremental backup. Default: empty. If given, then this backup becomes an incremental backup from given position or given backup. If value is 'auto', this backup will be taken from the last successful backup position.")
302-
BackupShard.Flags().BoolVar(&backupOptions.UpgradeSafe, "upgrade-safe", false, "Whether to use innodb_fast_shutdown=0 for the backup so it is safe to use for MySQL upgrades.")
307+
BackupShard.Flags().BoolVar(&backupShardOptions.UpgradeSafe, "upgrade-safe", false, "Whether to use innodb_fast_shutdown=0 for the backup so it is safe to use for MySQL upgrades.")
308+
BackupShard.Flags().DurationVar(&backupShardOptions.MysqlShutdownTimeout, "mysql-shutdown-timeout", mysqlctl.DefaultShutdownTimeout, "Timeout to use when MySQL is being shut down.")
303309
Root.AddCommand(BackupShard)
304310

305311
GetBackups.Flags().Uint32VarP(&getBackupsOptions.Limit, "limit", "l", 0, "Retrieve only the most recent N backups.")

go/flags/endtoend/vtcombo.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ Flags:
226226
--mysql-shell-load-flags string flags to pass to mysql shell load utility. This should be a JSON string (default "{\"threads\": 4, \"loadUsers\": true, \"updateGtidSet\": \"replace\", \"skipBinlog\": true, \"progressFile\": \"\"}")
227227
--mysql-shell-should-drain decide if we should drain while taking a backup or continue to serving traffic
228228
--mysql-shell-speedup-restore speed up restore by disabling redo logging and double write buffer during the restore process
229-
--mysql-shutdown-timeout duration timeout to use when MySQL is being shut down. (default 5m0s)
229+
--mysql-shutdown-timeout duration Timeout to use when MySQL is being shut down. (default 5m0s)
230230
--mysql_allow_clear_text_without_tls If set, the server will allow the use of a clear text password over non-SSL connections.
231231
--mysql_auth_server_impl string Which auth server implementation to use. Options: none, ldap, clientcert, static, vault. (default "static")
232232
--mysql_default_workload string Default session workload (OLTP, OLAP, DBA) (default "OLTP")

go/flags/endtoend/vttablet.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ Flags:
246246
--mysql-shell-load-flags string flags to pass to mysql shell load utility. This should be a JSON string (default "{\"threads\": 4, \"loadUsers\": true, \"updateGtidSet\": \"replace\", \"skipBinlog\": true, \"progressFile\": \"\"}")
247247
--mysql-shell-should-drain decide if we should drain while taking a backup or continue to serving traffic
248248
--mysql-shell-speedup-restore speed up restore by disabling redo logging and double write buffer during the restore process
249-
--mysql-shutdown-timeout duration timeout to use when MySQL is being shut down. (default 5m0s)
249+
--mysql-shutdown-timeout duration Timeout to use when MySQL is being shut down. (default 5m0s)
250250
--mysql_server_version string MySQL server version to advertise. (default "8.0.40-Vitess")
251251
--mysqlctl_mycnf_template string template file to use for generating the my.cnf file during server init
252252
--mysqlctl_socket string socket file to use for remote mysqlctl actions (empty for local actions)

0 commit comments

Comments
 (0)