Skip to content

Commit 5f587c3

Browse files
author
Shlomi Noach
committed
Adding --force-named-panic option
1 parent d5c374a commit 5f587c3

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

go/base/context.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ type MigrationContext struct {
123123
CutOverExponentialBackoff bool
124124
ExponentialBackoffMaxInterval int64
125125
ForceNamedCutOverCommand bool
126+
ForceNamedPanicCommand bool
126127
PanicFlagFile string
127128
HooksPath string
128129
HooksHintMessage string

go/cmd/gh-ost/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ func main() {
8181
flag.BoolVar(&migrationContext.TimestampOldTable, "timestamp-old-table", false, "Use a timestamp in old table name. This makes old table names unique and non conflicting cross migrations")
8282
cutOver := flag.String("cut-over", "atomic", "choose cut-over type (default|atomic, two-step)")
8383
flag.BoolVar(&migrationContext.ForceNamedCutOverCommand, "force-named-cut-over", false, "When true, the 'unpostpone|cut-over' interactive command must name the migrated table")
84+
flag.BoolVar(&migrationContext.ForceNamedPanicCommand, "force-named-panic", false, "When true, the 'panic' interactive command must name the migrated table")
8485

8586
flag.BoolVar(&migrationContext.SwitchToRowBinlogFormat, "switch-to-rbr", false, "let this tool automatically switch binary log format to 'ROW' on the replica, if needed. The format will NOT be switched back. I'm too scared to do that, and wish to protect you if you happen to execute another migration while this one is running")
8687
flag.BoolVar(&migrationContext.AssumeRBR, "assume-rbr", false, "set to 'true' when you know for certain your server uses 'ROW' binlog_format. gh-ost is unable to tell, event after reading binlog_format, whether the replication process does indeed use 'ROW', and restarts replication to be certain RBR setting is applied. Such operation requires SUPER privileges which you might not have. Setting this flag avoids restarting replication and you can proceed to use gh-ost without SUPER privileges")

go/logic/server.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,15 @@ help # This message
322322
}
323323
case "panic":
324324
{
325+
if arg == "" && this.migrationContext.ForceNamedPanicCommand {
326+
err := fmt.Errorf("User commanded 'panic' without specifying table name, but --force-named-panic is set")
327+
return NoPrintStatusRule, err
328+
}
329+
if arg != "" && arg != this.migrationContext.OriginalTableName {
330+
// User explicitly provided table name. This is a courtesy protection mechanism
331+
err := fmt.Errorf("User commanded 'panic' on %s, but migrated table is %s; ignoring request.", arg, this.migrationContext.OriginalTableName)
332+
return NoPrintStatusRule, err
333+
}
325334
err := fmt.Errorf("User commanded 'panic'. I will now panic, without cleanup. PANIC!")
326335
this.migrationContext.PanicAbort <- err
327336
return NoPrintStatusRule, err

0 commit comments

Comments
 (0)