Skip to content

Commit 1591acf

Browse files
author
Yves Trudeau
committed
DISTMYSQL-185, Modified the error returned when doing relocation to include the sub-errors where often the cause of the failure is explained
1 parent a091725 commit 1591acf

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

go/inst/instance_topology.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2813,8 +2813,10 @@ func relocateReplicasInternal(replicas [](*Instance), instance, other *Instance)
28132813

28142814
return RepointTo(replicas, &other.Key)
28152815
}
2816+
28162817
// GTID
2817-
{
2818+
if other.UsingGTID() {
2819+
28182820
movedReplicas, unmovedReplicas, err, errs := moveReplicasViaGTID(replicas, other, nil)
28192821

28202822
if len(movedReplicas) == len(replicas) {
@@ -2824,6 +2826,20 @@ func relocateReplicasInternal(replicas [](*Instance), instance, other *Instance)
28242826
// something was moved via GTID; let's try further on
28252827
return relocateReplicasInternal(unmovedReplicas, instance, other)
28262828
}
2829+
2830+
// Making sure that if there are any errors in errs, they are reported
2831+
if len(errs) > 0 {
2832+
// There are errors, maybe more than one. Let's concatenate them
2833+
// so they can be reported correctly in the UI
2834+
allErrors := "Error(s): "
2835+
2836+
for _, err := range errs {
2837+
allErrors = fmt.Sprintf("%s; %v",allErrors,err)
2838+
}
2839+
2840+
return movedReplicas, log.Errorf("Relocating %+v replicas of %+v below %+v failed %s", len(replicas), instance.Key, other.Key, allErrors), errs
2841+
2842+
}
28272843
// Otherwise nothing was moved via GTID. Maybe we don't have any GTIDs, we continue.
28282844
}
28292845

0 commit comments

Comments
 (0)