MCPcopy
hub / github.com/github/gh-ost / GetMasterConnectionConfigSafe

Function GetMasterConnectionConfigSafe

go/mysql/utils.go:132–160  ·  view source on GitHub ↗
(dbVersion string, connectionConfig *ConnectionConfig, visitedKeys *InstanceKeyMap, allowMasterMaster bool)

Source from the content-addressed store, hash-verified

130}
131
132func GetMasterConnectionConfigSafe(dbVersion string, connectionConfig *ConnectionConfig, visitedKeys *InstanceKeyMap, allowMasterMaster bool) (masterConfig *ConnectionConfig, err error) {
133 log.Debugf("Looking for %s on %+v", ReplicaTermFor(dbVersion, "master"), connectionConfig.Key)
134
135 masterKey, err := GetMasterKeyFromSlaveStatus(dbVersion, connectionConfig)
136 if err != nil {
137 return nil, err
138 }
139 if masterKey == nil {
140 return connectionConfig, nil
141 }
142 if !masterKey.IsValid() {
143 return connectionConfig, nil
144 }
145
146 masterConfig = connectionConfig.DuplicateCredentials(*masterKey)
147 if err := masterConfig.RegisterTLSConfig(); err != nil {
148 return nil, err
149 }
150
151 log.Debugf("%s of %+v is %+v", ReplicaTermFor(dbVersion, "master"), connectionConfig.Key, masterConfig.Key)
152 if visitedKeys.HasKey(masterConfig.Key) {
153 if allowMasterMaster {
154 return connectionConfig, nil
155 }
156 return nil, fmt.Errorf("there seems to be a master-master setup at %+v. This is unsupported. Bailing out", masterConfig.Key)
157 }
158 visitedKeys.AddKey(masterConfig.Key)
159 return GetMasterConnectionConfigSafe(dbVersion, masterConfig, visitedKeys, allowMasterMaster)
160}
161
162func GetReplicationBinlogCoordinates(dbVersion string, db *gosql.DB, gtid bool) (readBinlogCoordinates, executeBinlogCoordinates BinlogCoordinates, err error) {
163 showReplicaStatusQuery := fmt.Sprintf("show %s", ReplicaTermFor(dbVersion, `slave status`))

Callers 1

Calls 9

ReplicaTermForFunction · 0.85
IsValidMethod · 0.80
DuplicateCredentialsMethod · 0.80
RegisterTLSConfigMethod · 0.80
HasKeyMethod · 0.80
AddKeyMethod · 0.80
DebugfMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…