Skip to content

Commit 35752c9

Browse files
author
Shlomi Noach
authored
Merge pull request #78 from github/allow-master-master
adding --allow-master-master
2 parents b6d88dd + 690e046 commit 35752c9

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

go/base/context.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ type MigrationContext struct {
4343

4444
CountTableRows bool
4545
AllowedRunningOnMaster bool
46+
AllowedMasterMaster bool
4647
SwitchToRowBinlogFormat bool
4748
NullableUniqueKeyAllowed bool
4849
ApproveRenamedColumns bool

go/cmd/gh-ost/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ func main() {
5454
flag.StringVar(&migrationContext.AlterStatement, "alter", "", "alter statement (mandatory)")
5555
flag.BoolVar(&migrationContext.CountTableRows, "exact-rowcount", false, "actually count table rows as opposed to estimate them (results in more accurate progress estimation)")
5656
flag.BoolVar(&migrationContext.AllowedRunningOnMaster, "allow-on-master", false, "allow this migration to run directly on master. Preferably it would run on a replica")
57+
flag.BoolVar(&migrationContext.AllowedMasterMaster, "allow-master-master", false, "explicitly allow running in a master-master setup")
5758
flag.BoolVar(&migrationContext.NullableUniqueKeyAllowed, "allow-nullable-unique-key", false, "allow gh-ost to migrate based on a unique key with nullable columns. As long as no NULL values exist, this should be OK. If NULL values exist in chosen key, data may be corrupted. Use at your own risk!")
5859
flag.BoolVar(&migrationContext.ApproveRenamedColumns, "approve-renamed-columns", false, "in case your `ALTER` statement renames columns, gh-ost will note that and offer its interpretation of the rename. By default gh-ost does not proceed to execute. This flag approves that gh-ost's interpretation si correct")
5960
flag.BoolVar(&migrationContext.SkipRenamedColumns, "skip-renamed-columns", false, "in case your `ALTER` statement renames columns, gh-ost will note that and offer its interpretation of the rename. By default gh-ost does not proceed to execute. This flag tells gh-ost to skip the renamed columns, i.e. to treat what gh-ost thinks are renamed columns as unrelated columns. NOTE: you may lose column data")

go/logic/inspect.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,5 +534,5 @@ func (this *Inspector) readChangelogState() (map[string]string, error) {
534534

535535
func (this *Inspector) getMasterConnectionConfig() (applierConfig *mysql.ConnectionConfig, err error) {
536536
visitedKeys := mysql.NewInstanceKeyMap()
537-
return mysql.GetMasterConnectionConfigSafe(this.connectionConfig, visitedKeys)
537+
return mysql.GetMasterConnectionConfigSafe(this.connectionConfig, visitedKeys, this.migrationContext.AllowedMasterMaster)
538538
}

go/mysql/utils.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func GetMasterKeyFromSlaveStatus(connectionConfig *ConnectionConfig) (masterKey
8484
return masterKey, err
8585
}
8686

87-
func GetMasterConnectionConfigSafe(connectionConfig *ConnectionConfig, visitedKeys *InstanceKeyMap) (masterConfig *ConnectionConfig, err error) {
87+
func GetMasterConnectionConfigSafe(connectionConfig *ConnectionConfig, visitedKeys *InstanceKeyMap, allowMasterMaster bool) (masterConfig *ConnectionConfig, err error) {
8888
log.Debugf("Looking for master on %+v", connectionConfig.Key)
8989

9090
masterKey, err := GetMasterKeyFromSlaveStatus(connectionConfig)
@@ -102,10 +102,13 @@ func GetMasterConnectionConfigSafe(connectionConfig *ConnectionConfig, visitedKe
102102

103103
log.Debugf("Master of %+v is %+v", connectionConfig.Key, masterConfig.Key)
104104
if visitedKeys.HasKey(masterConfig.Key) {
105+
if allowMasterMaster {
106+
return connectionConfig, nil
107+
}
105108
return nil, fmt.Errorf("There seems to be a master-master setup at %+v. This is unsupported. Bailing out", masterConfig.Key)
106109
}
107110
visitedKeys.AddKey(masterConfig.Key)
108-
return GetMasterConnectionConfigSafe(masterConfig, visitedKeys)
111+
return GetMasterConnectionConfigSafe(masterConfig, visitedKeys, allowMasterMaster)
109112
}
110113

111114
func GetReplicationBinlogCoordinates(db *gosql.DB) (readBinlogCoordinates *BinlogCoordinates, executeBinlogCoordinates *BinlogCoordinates, err error) {

0 commit comments

Comments
 (0)