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

all things equal, prefer promoting instance without errant GTID #812

Merged
merged 1 commit into from
Feb 20, 2019
Merged
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions go/inst/instance_topology_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,17 @@ func TestSortInstancesDataCenterHint(t *testing.T) {
test.S(t).ExpectEquals(instances[0].Key, i810Key)
}

func TestSortInstancesGtidErrant(t *testing.T) {
instances, instancesMap := generateTestInstances()
for _, instance := range instances {
instance.ExecBinlogCoordinates = instances[0].ExecBinlogCoordinates
instance.GtidErrant = "00020192-1111-1111-1111-111111111111:1"
}
instancesMap[i810Key.StringCode()].GtidErrant = ""
sortInstances(instances)
test.S(t).ExpectEquals(instances[0].Key, i810Key)
}

func TestGetPriorityMajorVersionForCandidate(t *testing.T) {
{
instances, instancesMap := generateTestInstances()
Expand Down
4 changes: 4 additions & 0 deletions go/inst/instance_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ func (this *InstancesSorterByExec) Less(i, j int) bool {
if this.instances[j].DataCenter == this.dataCenter && this.instances[i].DataCenter != this.dataCenter {
return true
}
// Prefer if not having errant GTID
if this.instances[j].GtidErrant == "" && this.instances[i].GtidErrant != "" {
return true
}
// Prefer candidates:
if this.instances[j].PromotionRule.SmallerThan(this.instances[i].PromotionRule) {
return true
Expand Down