When you have assessed the failing transaction for any other appropriate actions as described previously (such as security considerations), count the number of events that you need to skip. One event normally corresponds to one SQL statement in the binary log, but note that statements that use AUTO_INCREMENT
or LAST_INSERT_ID()
count as two events in the binary log. When binary log transaction compression is in use, a compressed transaction payload (Transaction_payload_event
) is counted as a single counter value, so all the events inside it are skipped as a unit.
If you want to skip the complete transaction, you can count the events to the end of the transaction, or you can just skip the relevant event group. Remember that with SET GLOBAL sql_slave_skip_counter
, the replica continues to skip to the end of an event group. Make sure you do not skip too far forward and go into the next event group or transaction so that it is not also skipped.
Issue the SET
statement as follows, where N
is the number of events from the source to skip:
SET GLOBAL sql_slave_skip_counter = N
This statement cannot be issued if gtid_mode=ON
is set, or if the replication I/O and SQL threads are running.
The SET GLOBAL sql_slave_skip_counter
statement has no immediate effect. When you issue the START REPLICA | SLAVE
statement for the next time following this SET
statement, the new value for the system variable sql_slave_skip_counter
is applied, and the events are skipped. That START REPLICA | SLAVE
statement also automatically sets the value of the system variable back to 0. If the replica is a multi-source replica, when you issue that START REPLICA | SLAVE
statement, the FOR CHANNEL
clause is required. Make sure that you name the correct channel, otherwise events are skipped on the wrong channel.