adding --allow-master-master
This commit is contained in:
parent
b6d88ddece
commit
690e046c51
@ -43,6 +43,7 @@ type MigrationContext struct {
|
||||
|
||||
CountTableRows bool
|
||||
AllowedRunningOnMaster bool
|
||||
AllowedMasterMaster bool
|
||||
SwitchToRowBinlogFormat bool
|
||||
NullableUniqueKeyAllowed bool
|
||||
ApproveRenamedColumns bool
|
||||
|
@ -54,6 +54,7 @@ func main() {
|
||||
flag.StringVar(&migrationContext.AlterStatement, "alter", "", "alter statement (mandatory)")
|
||||
flag.BoolVar(&migrationContext.CountTableRows, "exact-rowcount", false, "actually count table rows as opposed to estimate them (results in more accurate progress estimation)")
|
||||
flag.BoolVar(&migrationContext.AllowedRunningOnMaster, "allow-on-master", false, "allow this migration to run directly on master. Preferably it would run on a replica")
|
||||
flag.BoolVar(&migrationContext.AllowedMasterMaster, "allow-master-master", false, "explicitly allow running in a master-master setup")
|
||||
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!")
|
||||
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")
|
||||
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")
|
||||
|
@ -534,5 +534,5 @@ func (this *Inspector) readChangelogState() (map[string]string, error) {
|
||||
|
||||
func (this *Inspector) getMasterConnectionConfig() (applierConfig *mysql.ConnectionConfig, err error) {
|
||||
visitedKeys := mysql.NewInstanceKeyMap()
|
||||
return mysql.GetMasterConnectionConfigSafe(this.connectionConfig, visitedKeys)
|
||||
return mysql.GetMasterConnectionConfigSafe(this.connectionConfig, visitedKeys, this.migrationContext.AllowedMasterMaster)
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ func GetMasterKeyFromSlaveStatus(connectionConfig *ConnectionConfig) (masterKey
|
||||
return masterKey, err
|
||||
}
|
||||
|
||||
func GetMasterConnectionConfigSafe(connectionConfig *ConnectionConfig, visitedKeys *InstanceKeyMap) (masterConfig *ConnectionConfig, err error) {
|
||||
func GetMasterConnectionConfigSafe(connectionConfig *ConnectionConfig, visitedKeys *InstanceKeyMap, allowMasterMaster bool) (masterConfig *ConnectionConfig, err error) {
|
||||
log.Debugf("Looking for master on %+v", connectionConfig.Key)
|
||||
|
||||
masterKey, err := GetMasterKeyFromSlaveStatus(connectionConfig)
|
||||
@ -102,10 +102,13 @@ func GetMasterConnectionConfigSafe(connectionConfig *ConnectionConfig, visitedKe
|
||||
|
||||
log.Debugf("Master of %+v is %+v", connectionConfig.Key, masterConfig.Key)
|
||||
if visitedKeys.HasKey(masterConfig.Key) {
|
||||
if allowMasterMaster {
|
||||
return connectionConfig, nil
|
||||
}
|
||||
return nil, fmt.Errorf("There seems to be a master-master setup at %+v. This is unsupported. Bailing out", masterConfig.Key)
|
||||
}
|
||||
visitedKeys.AddKey(masterConfig.Key)
|
||||
return GetMasterConnectionConfigSafe(masterConfig, visitedKeys)
|
||||
return GetMasterConnectionConfigSafe(masterConfig, visitedKeys, allowMasterMaster)
|
||||
}
|
||||
|
||||
func GetReplicationBinlogCoordinates(db *gosql.DB) (readBinlogCoordinates *BinlogCoordinates, executeBinlogCoordinates *BinlogCoordinates, err error) {
|
||||
|
Loading…
Reference in New Issue
Block a user