Skip to content

Commit 82110fc

Browse files
committed
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
1 parent dfde634 commit 82110fc

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

go/base/context.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ type MigrationContext struct {
109109
CutOverType CutOver
110110

111111
Hostname string
112+
OverrideApplierHostname string
112113
TableEngine string
113114
RowsEstimate int64
114115
RowsDeltaEstimate int64

go/cmd/gh-ost/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ func main() {
4444
migrationContext := base.GetMigrationContext()
4545

4646
flag.StringVar(&migrationContext.InspectorConnectionConfig.Key.Hostname, "host", "127.0.0.1", "MySQL hostname (preferably a replica, not the master)")
47+
flag.StringVar(&migrationContext.OverrideApplierHostname, "override-applier-host", "", "(with -allow-master-master), optionally specify which host should have changes applied to it")
4748
flag.IntVar(&migrationContext.InspectorConnectionConfig.Key.Port, "port", 3306, "MySQL port (preferably a replica, not the master)")
4849
flag.StringVar(&migrationContext.CliUser, "user", "", "MySQL user")
4950
flag.StringVar(&migrationContext.CliPassword, "password", "", "MySQL password")
@@ -161,6 +162,9 @@ func main() {
161162
}
162163
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.")
163164
}
165+
if migrationContext.OverrideApplierHostname != "" && !migrationContext.AllowedMasterMaster {
166+
log.Fatalf("--override-applier-host is only for use with --allow-master-amster")
167+
}
164168

165169
switch *cutOver {
166170
case "atomic", "default", "":

go/logic/migrator.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,9 @@ func (this *Migrator) initiateInspector() (err error) {
759759
if this.migrationContext.ApplierConnectionConfig, err = this.inspector.getMasterConnectionConfig(); err != nil {
760760
return err
761761
}
762+
if this.migrationContext.OverrideApplierHostname != "" {
763+
this.migrationContext.ApplierConnectionConfig.Key.Hostname = this.migrationContext.OverrideApplierHostname
764+
}
762765
if this.migrationContext.TestOnReplica || this.migrationContext.MigrateOnReplica {
763766
if this.migrationContext.InspectorIsAlsoApplier() {
764767
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")

0 commit comments

Comments
 (0)