How To Skip Replication Errors in GTID-Based Replication

December 8, 2022
Author
Mani Paluru
Share this Post:

Replication Errors in GTID-Based ReplicationIn this blog, I’m going to discuss how to easily skip the replication errors in GTID (Global Transaction Identifier)-based replication.

In the MySQL world, if replication is broken we all use the famous SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; to skip the replication error. It always works if it’s a traditional binlogs events-based replication and is helpful to quickly resume the replication. But does this same method work for GTID-based replication? Let’s see.

In GTID-based replication, skipping a replication error in a broken replica is not as simple as binlogs-based replication. We have one old blog postRepair MySQL 5.6 GTID replication by injecting empty transactions —where one of our colleagues showed us one way to skip and fix the replication.

Let’s get into action and see another way of skipping an errored transaction in GTID replication.

Let’s try skipping the error with SQL_SLAVE_SKIP_COUNTER:

As you can see we are unable to skip the error and we got an error message while skipping with SQL_SLAVE_SKIP_COUNTER. As per the error message, it was unable to skip as this replica is running with GTID_MODE = ON.

Let’s test the trick and skip this error:

Here we have stopped the replication and changed the GTID_MODE from ON to ON_PERMISSIVE (New transactions are GTID transactions. Replicated transactions can be either anonymous or GTID transactions) and skipped it using SQL_SLAVE_SKIP_COUNTER = 1 and started the replication.

Once replication is caught up, we need to set the  GTID_MODE back to ON.

The SQL SQL_SLAVE_SKIP_COUNTER must be defined as 0 in order for MySQL to permit changing the GTID_MODE from ON_PERMISSIVE to ON.

According to the MySQL documentation, there are four different GTID modes available as noted below

  • OFF: Both new and replicated transactions must be anonymous.
  • OFF_PERMISSIVE: New transactions are anonymous. Replicated transactions can be either anonymous or GTID transactions.
  • ON_PERMISSIVE: New transactions are GTID transactions. Replicated transactions can be either anonymous or GTID transactions.
  • ON: Both new and replicated transactions must be GTID transactions.

Conclusion: Changing the GTID_MODE online is available since MySQL 5.7.6, and hope this method helps in quickly skipping the errors. Please be aware that you are making data inconsistent between the primary and replica by skipping a transaction, so we might have to fix the data inconsistency. pt-table-checksum and pt-table-sync can help you with fixing data inconsistency. 

Looking for database support your team can count on?

Get Started with Percona Support Today!

Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Far
Enough.

Said no pioneer ever.
MySQL, PostgreSQL, InnoDB, MariaDB, MongoDB and Kubernetes are trademarks for their respective owners.
© 2026 Percona All Rights Reserved