How to Fix MySQL Error 4016 (ER_SQL_SLAVE_SKIP_COUNTER_USED_WITH_GTID_MODE_ON)
You trigger mysql error 4016 when you use the old skip counter while GTID mode runs. To fix it, inject an empty transaction matching the failing GTID or fix the underlying data mismatch. Database teams often see this warning when a replica stops on a bad query. Old habits lead admins to use the traditional counter to jump past the broken event. Modern replication tracks global transaction identifiers across the whole cluster instead of simple log positions. Because of this design, the engine bl
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You trigger mysql error 4016 when you use the old skip counter while GTID mode runs. To fix it, inject an empty transaction matching the failing GTID or fix the underlying data mismatch.
Database teams often see this warning when a replica stops on a bad query. Old habits lead admins to use the traditional counter to jump past the broken event. Modern replication tracks global transaction identifiers across the whole cluster instead of simple log positions. Because of this design, the engine blocks or restricts the legacy skip counter unless specific channel modes are active.
Why mysql error 4016 happens in GTID replication
In the official database rules, this event maps to SQLSTATE HY000. The engine reports that the skip counter only works for channels assigning GTIDs to anonymous transactions. When standard global transaction tracking is active, every change has a unique identifier across all nodes.
In older file and position replication, a replica only cared about its current binlog file and byte offset. Telling the replica to skip one event just moved that pointer forward by one step. With global identifiers, the replica compares its executed transaction set against the source server set.
If you try to skip an event by moving a counter, the global sets will not match. The source server will see the missing identifier and send the exact same transaction again. The engine raises code 4016 to warn you that the counter will not solve a standard GTID stall. It only allows the counter when a replica converts incoming anonymous events into local identifiers.
How to diagnose the stalled replication channel
Before you touch the replica state, check the replication status view on the failing node. Look at the worker thread logs to find the exact transaction identifier that stopped the SQL thread. You also need to read the error text that caused the worker to halt in the first place.
Most replication halts happen because of duplicate keys, missing rows, or schema changes that ran out of order. Compare the row data on the source node with the row data on the replica node. Finding the root data difference prevents you from hiding a much larger sync problem.
Single Sign-On (SSO) + MySQL Access Governance: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Never grant broad superuser roles to every developer just to inspect broken replica threads. Set up read roles that allow on-call staff to read replication status tables safely. Keep sensitive fields like emails, phone numbers, card numbers, and national IDs safe during checks. Data masking rewrites matched fields in results so staff can compare broken rows safely.
How to fix the error safely in production
Once you confirm that skipping the event will not corrupt your data, use the official GTID method. Instead of incrementing a counter, you must record an empty transaction with the exact failing identifier. First, stop the replica SQL thread if it is still trying to run.
Next, set the session transaction identifier to match the failing global identifier from the status log. Run a blank commit block with no data changes inside it, and then reset the session identifier back to automatic mode. When you start the replica thread again, the engine sees that the identifier is already in its executed set.
The replica will ignore the broken event from the source and move to the next change in the queue. After the channel catches up, run a table checksum tool during low traffic hours. This check confirms that your source and replica tables still hold identical records.
Inspect every MySQL query and response in flight
Static grants and network rules block bad logins. They cannot pause a risky query for review or mask emails in a result set. By design, hoop.dev sits inline in the MySQL protocol as a sidecar for your MySQL. For every plain query, prepared statement, or cursor an agent or human runs in production, hoop.dev decides to pass, mask, block, or hold it for review.
First, hoop.dev guardrails block banned actions before MySQL runs them, and an AI Analyzer you configure can score intent or escalate for approval. Next, hoop.dev data masking rewrites sensitive string columns in results in memory, and every verdict goes to the audit trail. Find the open-source binary on GitHub.
Frequently asked questions
What does SQLSTATE HY000 mean for code 4016?
SQLSTATE HY000 is a general error code used by the database engine for server rules. For code 4016, it flags that the legacy skip counter conflicts with standard GTID tracking.
When does the legacy skip counter still work?
The skip counter only takes effect on replication channels that assign new GTIDs to incoming anonymous transactions. Standard GTID channels ignore the counter and require an empty transaction injection instead.
Is it safe to skip a failing transaction in production?
Skipping a transaction is only safe after you verify the data on both nodes. If you skip an insert or update without checking, your replica data will drift from the source.
Related guides
In this post