@@ -2419,25 +2419,28 @@ func relocateBelowInternal(instance, other *Instance) (*Instance, error) {
2419
2419
if InstancesAreSiblings (instance , other ) && other .IsBinlogServer () {
2420
2420
return MoveBelow (& instance .Key , & other .Key )
2421
2421
}
2422
- instanceMaster , found , err := ReadInstance (& instance .MasterKey )
2423
- if err != nil || ! found {
2422
+ instanceMaster , _ , err := ReadInstance (& instance .MasterKey )
2423
+ if err != nil {
2424
2424
return instance , err
2425
2425
}
2426
- if instanceMaster .MasterKey .Equals (& other .Key ) && instanceMaster .IsBinlogServer () {
2426
+ if instanceMaster != nil && instanceMaster .MasterKey .Equals (& other .Key ) && instanceMaster .IsBinlogServer () {
2427
2427
// Moving to grandparent via binlog server
2428
2428
return Repoint (& instance .Key , & instanceMaster .MasterKey , GTIDHintDeny )
2429
2429
}
2430
2430
if other .IsBinlogServer () {
2431
- if instanceMaster .IsBinlogServer () && InstancesAreSiblings (instanceMaster , other ) {
2431
+ if instanceMaster != nil && instanceMaster .IsBinlogServer () && InstancesAreSiblings (instanceMaster , other ) {
2432
2432
// Special case: this is a binlog server family; we move under the uncle, in one single step
2433
2433
return Repoint (& instance .Key , & other .Key , GTIDHintDeny )
2434
2434
}
2435
2435
2436
2436
// Relocate to its master, then repoint to the binlog server
2437
2437
otherMaster , found , err := ReadInstance (& other .MasterKey )
2438
- if err != nil || ! found {
2438
+ if err != nil {
2439
2439
return instance , err
2440
2440
}
2441
+ if ! found {
2442
+ return instance , log .Errorf ("Cannot find master %+v" , other .MasterKey )
2443
+ }
2441
2444
if ! other .IsLastCheckValid {
2442
2445
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 )
2443
2446
}
@@ -2474,11 +2477,11 @@ func relocateBelowInternal(instance, other *Instance) (*Instance, error) {
2474
2477
}
2475
2478
}
2476
2479
// See if we need to MoveUp
2477
- if instanceMaster .MasterKey .Equals (& other .Key ) {
2480
+ if instanceMaster != nil && instanceMaster .MasterKey .Equals (& other .Key ) {
2478
2481
// Moving to grandparent--handles co-mastering writable case
2479
2482
return MoveUp (& instance .Key )
2480
2483
}
2481
- if instanceMaster .IsBinlogServer () {
2484
+ if instanceMaster != nil && instanceMaster .IsBinlogServer () {
2482
2485
// Break operation into two: move (repoint) up, then continue
2483
2486
if _ , err := MoveUp (& instance .Key ); err != nil {
2484
2487
return instance , err
0 commit comments