Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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.
Jump to
Jump to file
Failed to load files.
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