To skip failing transactions when GTIDs are not in use or are being phased in (gtid_mode
is OFF
, OFF_PERMISSIVE
, or ON_PERMISSIVE
), you can skip a specified number of events by issuing a SET GLOBAL sql_slave_skip_counter
statement. Alternatively, you can skip past an event or events by issuing a CHANGE MASTER TO
statement to move the source binary log position forward.
These methods are also suitable when you have enabled GTID assignment on a replication channel using the ASSIGN_GTIDS_TO_ANONYMOUS_TRANSACTIONS
option of the CHANGE REPLICATION SOURCE TO
statement.
When you use these methods, it is important to understand that you are not necessarily skipping a complete transaction, as is always the case with the GTID-based method described previously. These non-GTID-based methods are not aware of transactions as such, but instead operate on events. The binary log is organized as a sequence of groups known as event groups, and each event group consists of a sequence of events.
For transactional tables, an event group corresponds to a transaction.
For nontransactional tables, an event group corresponds to a single SQL statement.
A single transaction can contain changes to both transactional and nontransactional tables.
When you use a SET GLOBAL sql_slave_skip_counter
statement to skip events and the resulting position is in the middle of an event group, the replica continues to skip events until it reaches the end of the group. Execution then starts with the next event group. The CHANGE MASTER TO
statement does not have this function, so you must be careful to identify the correct location to restart replication at the beginning of an event group. However, using CHANGE MASTER TO
means you do not have to count the events that need to be skipped, as you do with a SET GLOBAL sql_slave_skip_counter
, and instead you can just specify the location to restart.