Skip to content

Commit 824c43f

Browse files
author
Shlomi Noach
committed
Merge pull request #211 from outbrain/merge-downstream-gh
Merge downstream gh
2 parents ed53215 + 4376b4c commit 824c43f

File tree

8 files changed

+1576
-7
lines changed

8 files changed

+1576
-7
lines changed

go/inst/instance_topology.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2419,25 +2419,28 @@ func relocateBelowInternal(instance, other *Instance) (*Instance, error) {
24192419
if InstancesAreSiblings(instance, other) && other.IsBinlogServer() {
24202420
return MoveBelow(&instance.Key, &other.Key)
24212421
}
2422-
instanceMaster, found, err := ReadInstance(&instance.MasterKey)
2423-
if err != nil || !found {
2422+
instanceMaster, _, err := ReadInstance(&instance.MasterKey)
2423+
if err != nil {
24242424
return instance, err
24252425
}
2426-
if instanceMaster.MasterKey.Equals(&other.Key) && instanceMaster.IsBinlogServer() {
2426+
if instanceMaster != nil && instanceMaster.MasterKey.Equals(&other.Key) && instanceMaster.IsBinlogServer() {
24272427
// Moving to grandparent via binlog server
24282428
return Repoint(&instance.Key, &instanceMaster.MasterKey, GTIDHintDeny)
24292429
}
24302430
if other.IsBinlogServer() {
2431-
if instanceMaster.IsBinlogServer() && InstancesAreSiblings(instanceMaster, other) {
2431+
if instanceMaster != nil && instanceMaster.IsBinlogServer() && InstancesAreSiblings(instanceMaster, other) {
24322432
// Special case: this is a binlog server family; we move under the uncle, in one single step
24332433
return Repoint(&instance.Key, &other.Key, GTIDHintDeny)
24342434
}
24352435

24362436
// Relocate to its master, then repoint to the binlog server
24372437
otherMaster, found, err := ReadInstance(&other.MasterKey)
2438-
if err != nil || !found {
2438+
if err != nil {
24392439
return instance, err
24402440
}
2441+
if !found {
2442+
return instance, log.Errorf("Cannot find master %+v", other.MasterKey)
2443+
}
24412444
if !other.IsLastCheckValid {
24422445
return instance, log.Errorf("Binlog server %+v is not reachable. It would take two steps to relocate %+v below it, and I won't even do the first step.", other.Key, instance.Key)
24432446
}
@@ -2474,11 +2477,11 @@ func relocateBelowInternal(instance, other *Instance) (*Instance, error) {
24742477
}
24752478
}
24762479
// See if we need to MoveUp
2477-
if instanceMaster.MasterKey.Equals(&other.Key) {
2480+
if instanceMaster != nil && instanceMaster.MasterKey.Equals(&other.Key) {
24782481
// Moving to grandparent--handles co-mastering writable case
24792482
return MoveUp(&instance.Key)
24802483
}
2481-
if instanceMaster.IsBinlogServer() {
2484+
if instanceMaster != nil && instanceMaster.IsBinlogServer() {
24822485
// Break operation into two: move (repoint) up, then continue
24832486
if _, err := MoveUp(&instance.Key); err != nil {
24842487
return instance, err

0 commit comments

Comments
 (0)