Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Avoiding infinite ancestry on circular replication #673

Merged
merged 2 commits into from
Nov 1, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions go/inst/instance_dao.go
Original file line number Diff line number Diff line change
Expand Up @@ -773,19 +773,28 @@ Cleanup:
waitGroup.Wait()

if instanceFound {
instance.AncestryUUID = strings.Trim(fmt.Sprintf("%s,%s", instance.AncestryUUID, instance.ServerUUID), ",")
if instance.IsCoMaster {
// Take co-master into account, and avoid infinite loop
instance.AncestryUUID = fmt.Sprintf("%s,%s", instance.MasterUUID, instance.ServerUUID)
} else {
instance.AncestryUUID = fmt.Sprintf("%s,%s", instance.AncestryUUID, instance.ServerUUID)
}
instance.AncestryUUID = strings.Trim(instance.AncestryUUID, ",")
if instance.ExecutedGtidSet != "" && instance.masterExecutedGtidSet != "" {
// Compare master & replica GTID sets, but ignore the sets that present the master's UUID.
// This is because orchestrator may pool master and replica at an inconvenient timing,
// such that the replica may _seems_ to have more entries than the master, when in fact
// it's just that the naster's probing is stale.
// redactedExecutedGtidSet := redactGtidSetUUID(instance.ExecutedGtidSet, instance.MasterUUID)
// redactedMasterExecutedGtidSet := redactGtidSetUUID(instance.masterExecutedGtidSet, instance.MasterUUID)
redactedExecutedGtidSet, _ := NewOracleGtidSet(instance.ExecutedGtidSet)
for _, uuid := range strings.Split(instance.AncestryUUID, ",") {
if uuid != instance.ServerUUID {
redactedExecutedGtidSet.RemoveUUID(uuid)
}
if instance.IsCoMaster && uuid == instance.ServerUUID {
// If this is a co-master, then this server is likely to show its own generated GTIDs as errant,
// because its co-master has not applied them yet
redactedExecutedGtidSet.RemoveUUID(uuid)
}
}
// Avoid querying the database if there's no point:
if !redactedExecutedGtidSet.IsEmpty() {
Expand Down Expand Up @@ -916,6 +925,7 @@ func ReadInstanceClusterAttributes(instance *Instance) (err error) {
if clusterName == clusterNameByInstanceKey {
// circular replication. Avoid infinite ++ on replicationDepth
replicationDepth = 0
ancestryUUID = ""
} // While the other stays "1"
}
instance.ClusterName = clusterName
Expand Down