Skip to content

Commit e5e0444

Browse files
author
Shlomi Noach
committed
supporting --force-named-cut-over
- when given, user _must_ specify table name and of course table name must match migrated table
1 parent 0a8be1d commit e5e0444

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

go/base/context.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ type MigrationContext struct {
9292
criticalLoad LoadMap
9393
PostponeCutOverFlagFile string
9494
CutOverLockTimeoutSeconds int64
95+
ForceNamedCutOverCommand bool
9596
PanicFlagFile string
9697
HooksPath string
9798
HooksHintMessage string

go/cmd/gh-ost/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ func main() {
7171
flag.BoolVar(&migrationContext.InitiallyDropOldTable, "initially-drop-old-table", false, "Drop a possibly existing OLD table (remains from a previous run?) before beginning operation. Default is to panic and abort if such table exists")
7272
flag.BoolVar(&migrationContext.InitiallyDropGhostTable, "initially-drop-ghost-table", false, "Drop a possibly existing Ghost table (remains from a previous run?) before beginning operation. Default is to panic and abort if such table exists")
7373
cutOver := flag.String("cut-over", "atomic", "choose cut-over type (default|atomic, two-step)")
74+
flag.BoolVar(&migrationContext.ForceNamedCutOverCommand, "force-named-cut-over", false, "When true, the 'unpostpone|cut-over' interactive command must name the migrated table")
7475

7576
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")
7677
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: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,14 @@ help # This message
231231
}
232232
case "unpostpone", "no-postpone", "cut-over":
233233
{
234-
if arg != "" {
235-
if arg != this.migrationContext.OriginalTableName {
236-
// User exlpicitly provided table name. This is a courtesy protection mechanism
237-
err := fmt.Errorf("User commanded 'unpostpone' on %s, but migrated table is %s; ingoring request.", arg, this.migrationContext.OriginalTableName)
238-
return NoPrintStatusRule, err
239-
}
234+
if arg == "" && this.migrationContext.ForceNamedCutOverCommand {
235+
err := fmt.Errorf("User commanded 'unpostpone' without specifying table name, but --force-named-cut-over is set")
236+
return NoPrintStatusRule, err
237+
}
238+
if arg != "" && arg != this.migrationContext.OriginalTableName {
239+
// User exlpicitly provided table name. This is a courtesy protection mechanism
240+
err := fmt.Errorf("User commanded 'unpostpone' on %s, but migrated table is %s; ingoring request.", arg, this.migrationContext.OriginalTableName)
241+
return NoPrintStatusRule, err
240242
}
241243
if atomic.LoadInt64(&this.migrationContext.IsPostponingCutOver) > 0 {
242244
atomic.StoreInt64(&this.migrationContext.UserCommandedUnpostponeFlag, 1)

0 commit comments

Comments
 (0)