Skip to content

Commit c0128a6

Browse files
committed
issue-731: Execute GTID_SUBTRACT() and wait until there are no more differences
1 parent 6576586 commit c0128a6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

clustering/operations.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,14 @@ func (p *managerProcess) configureReplica(ctx context.Context, ss *StatusSet, in
560560
}
561561
}
562562

563+
// if the binlog required by the replica instance is not existing in the new primary instance, some data may be missing when `CHANGE MASTER TO' is executed.
564+
// use SubtractGTID to ensure no data is missing when switching.
565+
if sub, err := op.SubtractGTID(ctx, ss.MySQLStatus[ss.Primary].GlobalVariables.PurgedGTID, ss.MySQLStatus[index].GlobalVariables.ExecutedGTID); err != nil {
566+
return false, err
567+
} else if sub != "" {
568+
return false, fmt.Errorf("new primary %d does not have binlog containing transactions %s required for instance %d", ss.Primary, sub, index)
569+
}
570+
563571
ai := dbop.AccessInfo{
564572
Host: ss.Cluster.PodHostname(ss.Primary),
565573
Port: constants.MySQLPort,

0 commit comments

Comments
 (0)