Common SQL Errors

MySQL Error 1858: ER_SQL_SLAVE_SKIP_COUNTER_NOT_SETTABLE_IN_GTID_MODE - How to Fix and Prevent

Galaxy Team
August 7, 2025

<p>The server is running with GTID_MODE=ON, so the legacy sql_slave_skip_counter variable cannot be used to skip transactions.</p>

Sign up for the latest in common SQL errors from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

What is MySQL error 1858 ER_SQL_SLAVE_SKIP_COUNTER_NOT_SETTABLE_IN_GTID_MODE?

<p>MySQL Error 1858 ER_SQL_SLAVE_SKIP_COUNTER_NOT_SETTABLE_IN_GTID_MODE occurs when you try to use sql_slave_skip_counter while GTID replication is enabled. Replace the counter with an empty GTID transaction for every event you need to bypass, then restart replication to resolve the issue.</p>

Error Highlights

Typical Error Message

sql_slave_skip_counter can not be set when the server is

Error Type

Replication Error

Language

MySQL

Symbol

ER_SQL_SLAVE_SKIP_COUNTER_NOT_SETTABLE_IN_GTID_MODE

Error Code

1858

SQL State

HY000

Explanation

Table of Contents

What does MySQL Error 1858 ER_SQL_SLAVE_SKIP_COUNTER_NOT_SETTABLE_IN_GTID_MODE mean?

MySQL raises error 1858 when a user attempts to set the sql_slave_skip_counter variable on a replica that is running with @@GLOBAL.GTID_MODE = ON. GTID replication no longer supports skipping events with this legacy counter.

The check was added in MySQL 5.7.1 to enforce transactional consistency. GTID replication tracks every transaction by a Global Transaction Identifier, so skipping by positional counter risks divergent data.

When does this error appear?

The message shows up immediately after executing SET GLOBAL sql_slave_skip_counter = N or changing the value through a configuration file while GTID mode is enabled on the server.

It can also surface indirectly when automation tools or legacy scripts still rely on sql_slave_skip_counter for error handling on replicas that have been upgraded to GTID.

Why is fixing it important?

Replication stops when the command fails, leaving the replica out of sync. An unsynchronized replica undermines high availability, read scaling, and disaster-recovery objectives.

Failing to address the error can also hide deeper data issues that must be investigated before resuming replication.

What Causes This Error?

The root cause is a mismatch between GTID replication requirements and the deprecated skip mechanism. GTID ensures every transaction is applied exactly once, so blindly skipping a number of events is forbidden.

The error is often triggered by leftover administrative habits, custom failover scripts, or monitoring systems unaware of GTID restrictions.

How to Fix MySQL Error 1858

Identify the exact GTID of the problematic transaction from SHOW SLAVE STATUS or performance_schema tables. Then create an empty transaction with the same GTID on the replica, effectively marking it as applied.

After injecting the fake transaction, restart the replica threads with START REPLICA or START SLAVE. Replication will continue from the next event.

Common Scenarios and Solutions

On a replica that stopped due to a duplicate primary-key error, use the retrieved_gtid_set to locate the conflicting GTID, inject an empty transaction, and restart replication.

If multiple consecutive transactions need skipping, repeat the empty-transaction procedure for each GTID rather than relying on a single counter value.

Best Practices to Avoid This Error

Remove every reference to sql_slave_skip_counter from maintenance scripts before enabling GTID. Always handle replication errors with explicit GTID transactions.

Monitor replicas with tools that understand GTID, and test failover routines after major version upgrades. Using Galaxy's modern SQL editor, store vetted skip procedures in shared Collections so the team executes the correct fix consistently.

Related Errors and Solutions

Error 1236 (ER_MASTER_FATAL_ERROR_READING_BINLOG) indicates a broken binary log file and may appear alongside 1858. Resolve by recloning or pointing to a valid log position.

Error 1593 (ER_SLAVE_FATAL_ERROR) covers replication halts due to other GTID mismatches. Empty transactions or re-initialization can help, depending on the scenario.

Common Causes

Legacy scripts calling sql_slave_skip_counter

Old automation still uses positional skipping even after GTID was enabled.

Manual troubleshooting via outdated documentation

DBAs follow pre-GTID guides that recommend sql_slave_skip_counter commands.

Mixed replication topology

Some replicas run in GTID mode while others use file-position, causing inconsistent administrative steps.

Version upgrades

Upgrading from MySQL 5.6 to 5.7+ activates GTID by default, exposing scripts that rely on the obsolete counter.

Related Errors

MySQL Error 1236: ER_MASTER_FATAL_ERROR_READING_BINLOG

Indicates the replica cannot read a binary log event. Often requires re-syncing the replica or changing master position.

MySQL Error 1593: ER_SLAVE_FATAL_ERROR

A generic replication fatal error, frequently triggered by GTID inconsistencies. Follow a similar empty-transaction or clone approach.

MySQL Error 1772: ER_SLAVE_RELAY_LOG_READ_FAILURE

Occurs when the relay log is corrupted. Purge and restart replication or reclone the replica.

FAQs

Can I still use sql_slave_skip_counter with GTID disabled?

Yes. The variable works when @@GLOBAL.GTID_MODE = OFF because replication reverts to file-position tracking.

How do I skip multiple GTID transactions quickly?

Create an empty transaction for each GTID using a loop in a shell script or stored procedure. Never bundle them into one counter.

Will injecting empty transactions break consistency?

No. Empty GTID transactions simply mark the events as applied without altering data, preserving GTID consistency across servers.

How does Galaxy help?

Galaxy lets teams store approved skip scripts in shared Collections, track execution history, and run commands directly in its fast SQL editor, reducing human error.

Start Querying with the Modern SQL Editor Today!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo