Skip to content

Commit

Permalink
issue-731: Execute GTID_SUBTRACT() and wait until there are no more d…
Browse files Browse the repository at this point in the history
…ifferences
  • Loading branch information
shunki-fujita committed Aug 28, 2024
1 parent 6576586 commit c0128a6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions clustering/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,14 @@ func (p *managerProcess) configureReplica(ctx context.Context, ss *StatusSet, in
}
}

// 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.
// use SubtractGTID to ensure no data is missing when switching.
if sub, err := op.SubtractGTID(ctx, ss.MySQLStatus[ss.Primary].GlobalVariables.PurgedGTID, ss.MySQLStatus[index].GlobalVariables.ExecutedGTID); err != nil {
return false, err
} else if sub != "" {
return false, fmt.Errorf("new primary %d does not have binlog containing transactions %s required for instance %d", ss.Primary, sub, index)
}

ai := dbop.AccessInfo{
Host: ss.Cluster.PodHostname(ss.Primary),
Port: constants.MySQLPort,
Expand Down

0 comments on commit c0128a6

Please sign in to comment.