When you have assessed the failing transaction for any other appropriate actions as described previously (such as security considerations), identify the coordinates (file and position) in the source's binary log that represent a suitable position to restart replication. This can be the start of the event group following the event that caused the issue, or the start of the next transaction. The replication I/O thread begins reading from the source at these coordinates the next time the thread starts, skipping the failing event. Make sure that you have identified the position accurately, because this statement does not take event groups into account.
Issue the CHANGE MASTER TO
statement as follows, where source_log_name
is the binary log file that contains the restart position, and source_log_pos
is the number representing the restart position as stated in the binary log file:
CHANGE MASTER TO MASTER_LOG_FILE='source_log_name
', MASTER_LOG_POS=source_log_pos
;
If the replica is a multi-source replica, you must use the FOR CHANNEL
clause to name the appropriate channel on the CHANGE MASTER TO
statement.
This statement cannot be issued if MASTER_AUTO_POSITION=1
is set, or if the replication I/O and SQL threads are running. If you need to use this method of skipping a transaction when MASTER_AUTO_POSITION=1
is normally set, you can change the setting to MASTER_AUTO_POSITION=0
while issuing the statement, then change it back again afterwards. For example:
CHANGE MASTER TO MASTER_AUTO_POSITION=0, MASTER_LOG_FILE='binlog.000145', MASTER_LOG_POS=235; CHANGE MASTER TO MASTER_AUTO_POSITION=1;