Skip to content

Commit

Permalink
Merge pull request #812 from github/prefer-not-gtid-errant
Browse files Browse the repository at this point in the history
all things equal, prefer promoting instance without errant GTID
  • Loading branch information
Shlomi Noach committed Feb 20, 2019
2 parents 36f055a + 5237794 commit 33bcd5c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
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

0 comments on commit 33bcd5c

Please sign in to comment.