MySQL error 1202 stops replication when the system cannot create slave threads. This typically indicates insufficient memory, thread limits, or other resource constraints. Resolve by checking system resources, adjusting ulimit settings, or restarting the replication process.
ERROR 1202 (ER_SLAVE_THREAD) occurs when MySQL replication fails because the system cannot allocate resources to create a replica thread. This error indicates that the slave (now called replica in MySQL 8.0+) thread has stopped and needs to be restarted. The error message explicitly tells you to "check system resources," which typically means the server is running low on memory, threads are exhausted, or system limits are preventing thread creation. In MySQL 8.0.33+, this error was renamed from ER_SLAVE_THREAD to ER_REPLICA_THREAD with the updated message "Could not create replica thread; check system resources," but the underlying cause remains the same.
Connect to the slave server and verify its current state:
SHOW SLAVE STATUS\GLook for the values of Slave_IO_Running and Slave_SQL_Running. If either is "No", replication has stopped. Check the Last_Error field for the exact error message.
Verify that the server has sufficient available memory:
free -h
# or on macOS
vm_statAlso check MySQL memory allocation:
SHOW GLOBAL STATUS LIKE 'max_used_connections';
SHOW GLOBAL VARIABLES LIKE 'max_connections';If memory usage is above 85-90% of available RAM, you need to free up resources or add more memory.
On Linux, verify ulimit settings for the mysqld process:
# Check current limits for the MySQL process
cat /proc/$(pidof mysqld)/limits
# Or check as the mysql user
ulimit -aKey limits to check:
- max user processes: Should be higher than max_connections (default 151)
- open files: Should be at least 65535
If limits are too low, increase them by editing /etc/security/limits.conf:
mysql soft nofile 65535
mysql hard nofile 65535
mysql soft nproc 65535
mysql hard nproc 65535Then restart MySQL.
Once resources are available, restart the replication process:
-- Stop the slave
STOP SLAVE;
-- Clear the relay logs
RESET SLAVE;
-- If needed, reconfigure replication
CHANGE MASTER TO
MASTER_HOST='master_host',
MASTER_USER='replication_user',
MASTER_PASSWORD='password',
MASTER_LOG_FILE='mysql-bin.000001',
MASTER_LOG_POS=154;
-- Start the slave
START SLAVE;
-- Verify status
SHOW SLAVE STATUS\GWait a moment and check the status again to ensure both Slave_IO_Running and Slave_SQL_Running are "Yes".
If increasing system limits doesn't resolve the issue, reduce MySQL's thread stack memory usage:
SHOW GLOBAL VARIABLES LIKE 'thread_stack';The default is usually 262144 bytes (256KB). If memory is still constrained, you can reduce this in your MySQL configuration file:
[mysqld]
thread_stack = 192KThen restart MySQL. Note: Only reduce this if you're experiencing stack overflow errors; too low a value can cause crashes.
To prevent this error from recurring:
1. Regularly monitor replication status: Set up automated checks for SHOW SLAVE STATUS
2. Monitor system resources: Use tools like htop, Prometheus, or your cloud provider's monitoring
3. Set replication alerts: Configure MySQL to alert when Seconds_Behind_Master exceeds a threshold
4. Plan capacity: Ensure your slave has at least as much memory as the master
5. Use parallel replication (MySQL 5.7+): Enable multithreaded replication for better performance:
STOP SLAVE;
SET GLOBAL slave_parallel_workers = 4;
SET GLOBAL slave_parallel_type = 'LOGICAL_CLOCK';
START SLAVE;However, on low-resource systems, reduce parallel workers or set to 0.
For MySQL 8.0.33+, note that the error symbol changed from ER_SLAVE_THREAD to ER_REPLICA_THREAD with updated message text, but troubleshooting is identical. If you're using row-based replication (RBR) with large transactions, MySQL 5.6.21+ and 5.7.5+ fixed a memory leak where virtual temporary tables weren't freed mid-transaction. If you're on an older version and replicating massive transactions, upgrade to a patched version. On AWS RDS, if experiencing replication errors, try disabling multithreaded replication by setting replica_parallel_workers to 0. In container/Docker environments, ensure the MySQL container has sufficient memory allocation (--memory flag or docker-compose limits) and that the host has adequate swap configured.
EE_WRITE (3): Error writing file
How to fix "EE_WRITE (3): Error writing file" in MySQL
CR_PARAMS_NOT_BOUND (2031): No data supplied for parameters
How to fix "CR_PARAMS_NOT_BOUND (2031): No data supplied for parameters" in MySQL
CR_DNS_SRV_LOOKUP_FAILED (2070): DNS SRV lookup failed
How to fix "CR_DNS_SRV_LOOKUP_FAILED (2070): DNS SRV lookup failed" in MySQL
ERROR 1146: Table 'database.table' doesn't exist
How to fix "ERROR 1146: Table doesn't exist" in MySQL
ERROR 1040: Too many connections
How to fix "ERROR 1040: Too many connections" in MySQL