Common SQL Errors

MySQL Error 1875: ER_STOP_SLAVE_SQL_THREAD_TIMEOUT - How to Diagnose and Fix

Galaxy Team
August 8, 2025

The replica SQL thread did not stop within replication_stop_timeout after receiving a STOP SLAVE signal.

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 error code 1875 (ER_STOP_SLAVE_SQL_THREAD_TIMEOUT)?

ER_STOP_SLAVE_SQL_THREAD_TIMEOUT signals that the replica SQL thread could not finish its current work before the stop timeout expired. Raise replication_stop_timeout or wait for the thread to complete, then reissue STOP SLAVE to resolve the issue.

Error Highlights

Typical Error Message

ER_STOP_SLAVE_SQL_THREAD_TIMEOUT

Error Type

Replication Error

Language

MySQL

Symbol

thread got the stop signal, thread is busy, SQL thread will stop once the current task is complete. ER_STOP_SLAVE_SQL_THREAD_TIMEOUT was added in 5.7.2.

Error Code

1875

SQL State

HY000

Explanation

Table of Contents

What is MySQL error 1875 ER_STOP_SLAVE_SQL_THREAD_TIMEOUT?

MySQL raises error 1875 when the STOP SLAVE or STOP REPLICA command waits longer than replication_stop_timeout for the replica SQL thread to finish its current event batch. The feature was added in 5.7.2 to prevent indefinite waits during replication shutdown.

The message means the SQL thread has acknowledged the stop signal but is still executing statements. Once the timeout expires, MySQL surfaces ER_STOP_SLAVE_SQL_THREAD_TIMEOUT and leaves the thread running.

What Causes This Error?

Long running transactions or heavy DDL on the source can hold the SQL thread past the timeout. Each statement must complete before the thread stops, so large event groups increase wait time.

I/O or network stalls that slow statement apply rates also extend stop waits. Low replication_stop_timeout values make the error more likely on busy replicas.

How to Fix ER_STOP_SLAVE_SQL_THREAD_TIMEOUT

First, identify whether the SQL thread is still progressing. Check Seconds_Behind_Source and Last_SQL_Error in SHOW REPLICA STATUS. If progress continues, simply wait and re-issue STOP SLAVE once it finishes.

If you must stop replication quickly, raise replication_stop_timeout and try again. For stubborn blocks, kill the blocking query, or skip events with SET GLOBAL sql_slave_skip_counter.

Common Scenarios and Solutions

During planned maintenance, replicas running large ALTER TABLE statements often show this error. In that case, allow the statement to finish or change channel to applier stop timeout to a higher value before maintenance.

When a user accidentally runs a massive update on the primary, replicas can take hours to apply it. Temporarily increasing replication_stop_timeout lets STOP SLAVE wait long enough to finish.

Best Practices to Avoid This Error

Set replication_stop_timeout based on the longest transaction you expect. Values between 300 and 900 seconds work for most workloads.

Monitor long running queries and replica lag with Galaxy or other tools. Galaxy’s live query view helps you detect heavy statements before they block a STOP SLAVE operation.

Related Errors and Solutions

ER_STOP_SLAVE_IO_THREAD_TIMEOUT (1964) appears when the I/O thread cannot stop within its timeout. ER_REPLICA_SQL_THREAD_STOPPED can follow if you manually kill the SQL thread. Fixes are similar - increase the timeout or wait for completion.

Common Causes

Long running transaction

Multi-row updates, deletes, or batch inserts can keep the SQL thread busy for minutes, causing the stop timeout to expire.

Heavy DDL statement

ALTER TABLE and OPTIMIZE TABLE operations replicate as single events that must finish before the thread halts.

Disk or network bottleneck

Slow storage or network latency reduces apply throughput, lengthening the time needed to finish current events.

Low replication_stop_timeout

A default of 30 seconds may be too small for production workloads, leading to frequent timeouts.

Related Errors

Error 1964 ER_STOP_SLAVE_IO_THREAD_TIMEOUT

Timeout while waiting for the I/O thread to stop. Increase replication_stop_timeout_io to fix.

Error 1872 ER_REPLICA_SQL_THREAD_STOPPED

Indicates the SQL thread has been stopped manually or due to an error. Review Last_SQL_Error for details.

Error 1201 ER_HA_ERR_FOUND_DUPP_KEY

Duplicate key error in the SQL thread that can also block STOP SLAVE until skipped or fixed.

FAQs

How long should replication_stop_timeout be?

Set the value longer than your typical longest transaction. Many teams use 300-900 seconds in production.

Does the error harm data consistency?

No. MySQL leaves the SQL thread running. Data remains consistent; only the stop request fails.

Can I force kill the SQL thread safely?

Killing the thread aborts the current transaction and may require recovery with START REPLICA UNTIL SQL_BEFORE_GTIDS. Use it only when maintenance windows demand immediate stop.

How does Galaxy help?

Galaxy highlights long running replica queries and surfaces real-time lag, enabling you to adjust timeouts proactively before issuing STOP SLAVE.

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