From 82110fcfcfa1a3dcea16ef74083eb9d1c74d5744 Mon Sep 17 00:00:00 2001 From: randall Date: Thu, 1 Sep 2016 20:29:26 -0700 Subject: [PATCH] Add -override-applier-host for use with -allow-master-master for configurations where writes are meant to go to one master, but gh-ost can't automatically determine which --- go/base/context.go | 1 + go/cmd/gh-ost/main.go | 4 ++++ go/logic/migrator.go | 3 +++ 3 files changed, 8 insertions(+) diff --git a/go/base/context.go b/go/base/context.go index 8d988ea..d6a931d 100644 --- a/go/base/context.go +++ b/go/base/context.go @@ -109,6 +109,7 @@ type MigrationContext struct { CutOverType CutOver Hostname string + OverrideApplierHostname string TableEngine string RowsEstimate int64 RowsDeltaEstimate int64 diff --git a/go/cmd/gh-ost/main.go b/go/cmd/gh-ost/main.go index 115829a..38c8466 100644 --- a/go/cmd/gh-ost/main.go +++ b/go/cmd/gh-ost/main.go @@ -44,6 +44,7 @@ func main() { migrationContext := base.GetMigrationContext() flag.StringVar(&migrationContext.InspectorConnectionConfig.Key.Hostname, "host", "127.0.0.1", "MySQL hostname (preferably a replica, not the master)") + flag.StringVar(&migrationContext.OverrideApplierHostname, "override-applier-host", "", "(with -allow-master-master), optionally specify which host should have changes applied to it") flag.IntVar(&migrationContext.InspectorConnectionConfig.Key.Port, "port", 3306, "MySQL port (preferably a replica, not the master)") flag.StringVar(&migrationContext.CliUser, "user", "", "MySQL user") flag.StringVar(&migrationContext.CliPassword, "password", "", "MySQL password") @@ -161,6 +162,9 @@ func main() { } log.Warning("--test-on-replica-skip-replica-stop enabled. We will not stop replication before cut-over. Ensure you have a plugin that does this.") } + if migrationContext.OverrideApplierHostname != "" && !migrationContext.AllowedMasterMaster { + log.Fatalf("--override-applier-host is only for use with --allow-master-amster") + } switch *cutOver { case "atomic", "default", "": diff --git a/go/logic/migrator.go b/go/logic/migrator.go index e9c1426..8bf7641 100644 --- a/go/logic/migrator.go +++ b/go/logic/migrator.go @@ -759,6 +759,9 @@ func (this *Migrator) initiateInspector() (err error) { if this.migrationContext.ApplierConnectionConfig, err = this.inspector.getMasterConnectionConfig(); err != nil { return err } + if this.migrationContext.OverrideApplierHostname != "" { + this.migrationContext.ApplierConnectionConfig.Key.Hostname = this.migrationContext.OverrideApplierHostname + } if this.migrationContext.TestOnReplica || this.migrationContext.MigrateOnReplica { if this.migrationContext.InspectorIsAlsoApplier() { return fmt.Errorf("Instructed to --test-on-replica or --migrate-on-replica, but the server we connect to doesn't seem to be a replica")