MySQL blocks replication changes because the channel's IO thread is still running.
MySQL Error 3021 ER_SLAVE_CHANNEL_IO_THREAD_MUST_STOP occurs when you alter replication while the channel's IO thread is active. Stop the thread with STOP SLAVE IO_THREAD FOR CHANNEL 'channel_name', apply your change, then restart replication to resolve the issue.
ER_SLAVE_CHANNEL_IO_THREAD_MUST_STOP
MySQL raises error 3021 ER_SLAVE_CHANNEL_IO_THREAD_MUST_STOP when a replication statement attempts to modify a channel that still has its IO thread running. The server blocks the request to protect replication consistency.
The error appears from MySQL 5.7.6 onward and affects operations such as CHANGE MASTER TO, RESET SLAVE, or channel deletion. Administrators must stop the IO thread first, otherwise the request fails with SQL state HY000.
The primary trigger is an active IO thread on the targeted replica channel. While the thread fetches binary log events, MySQL rejects configuration changes that could corrupt state.
Running START SLAVE or START REPLICA automatically starts the IO thread, so any subsequent CHANGE MASTER TO or RESET SLAVE requires an explicit STOP SLAVE IO_THREAD FOR CHANNEL clause before execution.
Stop the IO thread for the affected channel, rerun the intended replication command, then restart replication. This three-step sequence resolves the error without data loss.
Confirm the IO thread is stopped by checking the Slave_IO_Running column in SHOW SLAVE STATUS or Performance Schema replication_connection_status.
When re-pointing a replica to a new source, first stop only the IO thread, apply CHANGE MASTER TO, and finally start both threads with START SLAVE.
If you need to purge relay logs, stop the IO thread, issue PURGE BINARY LOGS or RESET SLAVE, then restart replication.
Automate replication maintenance scripts to always stop the IO thread before configuration changes. Embed defensive checks that query Slave_IO_Running and exit early if the thread is active.
Adopt channel-specific commands (STOP SLAVE IO_THREAD FOR CHANNEL 'name') in multi-source setups to limit impact on other channels.
Error 3022 ER_SLAVE_CHANNEL_SQL_THREAD_MUST_STOP appears when the SQL thread is still running. The fix is analogous: STOP SLAVE SQL_THREAD FOR CHANNEL before altering replication.
Error 3081 ER_BINLOG_UNSAFE_NONTRANS_AFTER_TRANS shows when non-transactional tables are updated after transactional ones in a statement. Use row-based logging or reorder updates.
START SLAVE or START REPLICA left the IO thread running, so MySQL refuses CHANGE MASTER TO or RESET SLAVE until the thread stops.
Maintenance jobs trigger replication changes without first querying Slave_IO_Running, causing the error during busy periods.
Administrators change one channel but forget that its IO thread is fetching events while other channels stay idle, leading to a targeted failure.
Raised when the SQL thread is active during configuration changes. Stop the SQL thread with STOP SLAVE SQL_THREAD FOR CHANNEL first.
Occurs when you attempt to stop an IO thread that is already stopped. Verify thread status before issuing STOP SLAVE.
Indicates unsafe mixed updates in statement-based logging. Switch to row-based logging or reorder statements.
Not always. Error 3021 only requires the IO thread to stop, but stopping both threads is safer when making major replication changes.
No. The IO thread only fetches events. Stopping it pauses replication but does not drop data or logs.
Run SHOW SLAVE STATUS and look at the Slave_IO_Running column. A value of Yes means the thread is active.
Yes. Galaxy's SQL editor lets you script replication changes with built-in version control, making it easy to include STOP SLAVE commands and share validated procedures with your team.