From 9b5610bf0f59e9584fca7c91665f418f0a5815bc Mon Sep 17 00:00:00 2001 From: Shlomi Noach Date: Mon, 29 Oct 2018 22:19:32 +0200 Subject: [PATCH 1/2] Avoiding infinite ancestry on circular replication --- go/inst/instance_dao.go | 1 + 1 file changed, 1 insertion(+) diff --git a/go/inst/instance_dao.go b/go/inst/instance_dao.go index 624718cfe..db546b839 100644 --- a/go/inst/instance_dao.go +++ b/go/inst/instance_dao.go @@ -916,6 +916,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 From 3bf999f2fec7b8fe30849c0963791ca6a9432ac7 Mon Sep 17 00:00:00 2001 From: Shlomi Noach Date: Tue, 30 Oct 2018 08:00:32 +0200 Subject: [PATCH 2/2] ancestry_uuid further fixed for co-masters (now both co-masters include each other). Errant GTID ignores transactions injected by a server in a co-master setup --- go/inst/instance_dao.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/go/inst/instance_dao.go b/go/inst/instance_dao.go index db546b839..07657ba35 100644 --- a/go/inst/instance_dao.go +++ b/go/inst/instance_dao.go @@ -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() {