How to Fix MySQL Error 1875 (ER_STOP_SLAVE_SQL_THREAD_TIMEOUT)
You see mysql error 1875 when a replica SQL thread fails to stop in time. You fix it by finding the busy query or lock and clearing the blocker. MySQL maps this issue to ER_STOP_SLAVE_SQL_THREAD_TIMEOUT and SQLSTATE HY000. The server reports that the stop command is not done yet. The SQL thread got the stop signal, stays busy, and will stop later. Root causes of mysql error 1875 A MySQL replica uses two main worker threads to copy data from a source. One thread reads changes from the source,
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 see mysql error 1875 when a replica SQL thread fails to stop in time. You fix it by finding the busy query or lock and clearing the blocker.
MySQL maps this issue to ER_STOP_SLAVE_SQL_THREAD_TIMEOUT and SQLSTATE HY000. The server reports that the stop command is not done yet. The SQL thread got the stop signal, stays busy, and will stop later.
Root causes of mysql error 1875
A MySQL replica uses two main worker threads to copy data from a source. One thread reads changes from the source, and the SQL thread runs those changes. When you ask the replica to stop, MySQL sends a stop signal. The SQL thread cannot pause in the middle of an unsafe step.
Large batch updates often trigger this timeout on busy database servers. If a single statement changes millions of rows, the SQL thread must finish first. Stopping halfway through a non-transactional table change would leave replica data broken. The worker ignores the pause request until the current event finishes or rolls back.
Metadata locks on the replica also cause the SQL thread to hang. A reporting app or user session might hold an open read transaction on a table. If the SQL thread tries to alter that same table, it waits for the lock. Because the thread is stuck waiting, it cannot finish the stop request before the timer ends.
Slow disks and heavy server load make this delay much worse. When the storage system falls behind on writes, rolling back a huge transaction takes minutes. The stop command hits its wait limit and returns error 1875 to your client. Meanwhile, the SQL thread keeps working in the background until it reaches a safe point.
How to diagnose and fix the replica timeout
Start by checking the active process list on the replica server. Look at the state of the SQL thread to see what it is doing. If the state shows it is applying a batch of changes, check the transaction size. Wait for the disk work to finish rather than forcing a hard server crash.
MySQL Access Governance + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
If the thread state shows a lock wait, find the blocking session right away. Check open transactions on the replica to see which user holds the table lock. Ending the read query on the replica frees the lock right away. Once the lock clears, the SQL thread finishes its task and stops on its own.
Do not restart the whole MySQL service just to clear a stuck stop command. A forced restart during a huge rollback forces crash recovery when the server boots up. Instead, fix the root cause by breaking huge source updates into smaller batches. Keep reporting queries short on replicas so they do not block incoming schema changes.
Preventing replica lock delays in production
Good access controls help your team avoid replica lock issues during daily work. Give reporting apps and engineers read-only roles with strict query timeouts on replicas. When ad-hoc queries cannot run for hours, they cannot hold metadata locks for long. You also reduce the risk of someone running heavy writes in the wrong place.
Masking sensitive fields in query results also reduces the need for raw table dumps. When a system rewrites emails, phone numbers, card numbers, and national IDs, engineers work safer. Teams can check replica state and active locks without broad admin rights. Clear audit logs show which session held a lock when a replica stop timed out.
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
Does mysql error 1875 mean my replica data is corrupted?
No, this error only means the stop command timed out while waiting. The SQL thread is still working to reach a safe stopping point to protect your data.
Should I kill the SQL thread when I see ER_STOP_SLAVE_SQL_THREAD_TIMEOUT?
Do not kill the worker thread directly if it is rolling back a big change. Instead, kill any user read queries on the replica that block the SQL thread.
How can I prevent error 1875 during schema migrations?
Stop long-running read queries on the replica before you send schema changes from the source. Splitting large data updates into small chunks also helps the SQL thread stop fast.
Related guides
In this post