From e5e0444cc6f3ffa2b4da7608fb48496e4f18e709 Mon Sep 17 00:00:00 2001 From: Shlomi Noach Date: Mon, 12 Sep 2016 19:17:36 +0200 Subject: [PATCH] supporting --force-named-cut-over - when given, user _must_ specify table name and of course table name must match migrated table --- go/base/context.go | 1 + go/cmd/gh-ost/main.go | 1 + go/logic/server.go | 14 ++++++++------ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/go/base/context.go b/go/base/context.go index d1f2d10..41aa915 100644 --- a/go/base/context.go +++ b/go/base/context.go @@ -92,6 +92,7 @@ type MigrationContext struct { criticalLoad LoadMap PostponeCutOverFlagFile string CutOverLockTimeoutSeconds int64 + ForceNamedCutOverCommand bool PanicFlagFile string HooksPath string HooksHintMessage string diff --git a/go/cmd/gh-ost/main.go b/go/cmd/gh-ost/main.go index 14960ff..9231269 100644 --- a/go/cmd/gh-ost/main.go +++ b/go/cmd/gh-ost/main.go @@ -71,6 +71,7 @@ func main() { 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") 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") cutOver := flag.String("cut-over", "atomic", "choose cut-over type (default|atomic, two-step)") + flag.BoolVar(&migrationContext.ForceNamedCutOverCommand, "force-named-cut-over", false, "When true, the 'unpostpone|cut-over' interactive command must name the migrated table") 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") 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") diff --git a/go/logic/server.go b/go/logic/server.go index 64906c4..b8c0f2c 100644 --- a/go/logic/server.go +++ b/go/logic/server.go @@ -231,12 +231,14 @@ help # This message } case "unpostpone", "no-postpone", "cut-over": { - if arg != "" { - if arg != this.migrationContext.OriginalTableName { - // User exlpicitly provided table name. This is a courtesy protection mechanism - err := fmt.Errorf("User commanded 'unpostpone' on %s, but migrated table is %s; ingoring request.", arg, this.migrationContext.OriginalTableName) - return NoPrintStatusRule, err - } + if arg == "" && this.migrationContext.ForceNamedCutOverCommand { + err := fmt.Errorf("User commanded 'unpostpone' without specifying table name, but --force-named-cut-over is set") + return NoPrintStatusRule, err + } + if arg != "" && arg != this.migrationContext.OriginalTableName { + // User exlpicitly provided table name. This is a courtesy protection mechanism + err := fmt.Errorf("User commanded 'unpostpone' on %s, but migrated table is %s; ingoring request.", arg, this.migrationContext.OriginalTableName) + return NoPrintStatusRule, err } if atomic.LoadInt64(&this.migrationContext.IsPostponingCutOver) > 0 { atomic.StoreInt64(&this.migrationContext.UserCommandedUnpostponeFlag, 1)