Error
Error Code:
1802
MySQL Error 1802: CHANGE MASTER with MTS Gaps
Description
This error indicates that the `CHANGE MASTER` command cannot be executed on a MySQL replication slave. It occurs specifically when the slave, operating in Multi-Threaded Slave (MTS) mode, has stopped due to an error or was killed, leaving potential gaps or inconsistencies in its replication state. The command is blocked to prevent further replication issues until the slave's state is resolved.
Error Message
CHANGE MASTER cannot be executed when the slave was stopped with an error or killed in MTS mode. Consider using RESET SLAVE or START SLAVE UNTIL.
Known Causes
3 known causesSlave Stopped with Error (MTS Mode)
The replication slave encountered an error during its operation in Multi-Threaded Slave (MTS) mode and subsequently stopped, leaving its state potentially inconsistent.
Slave Process Abruptly Terminated
The MySQL slave process was unexpectedly killed or terminated while actively replicating in Multi-Threaded Slave (MTS) mode, which can lead to uncommitted transactions or gaps.
Replication Gaps or Inconsistencies
The slave's relay log or master log positions are out of sync or have gaps due to an unexpected stop, preventing `CHANGE MASTER` from being safely applied.
Solutions
3 solutions available1. Reset Slave Configuration easy
Completely clears the slave's replication state and allows re-configuration.
1
Connect to your MySQL slave server using a MySQL client.
2
Execute the RESET SLAVE command. This will remove all replication-related information from the slave.
RESET SLAVE;
3
After resetting, you can proceed with your CHANGE MASTER command to re-establish replication.
CHANGE MASTER TO MASTER_HOST='<master_host>', MASTER_USER='<master_user>', MASTER_PASSWORD='<master_password>', MASTER_LOG_FILE='<master_log_file>', MASTER_LOG_POS=<master_log_pos>;
4
Start the slave threads.
START SLAVE;
2. Start Slave Until a Specific Point medium
Safely brings the slave up to a known good replication point.
1
Connect to your MySQL slave server.
2
Before executing CHANGE MASTER, determine the last known good binary log file and position from your master. You can usually find this by looking at the master's `SHOW MASTER STATUS;` output or by examining the slave's error log for the point where it stopped.
3
Execute the CHANGE MASTER command.
CHANGE MASTER TO MASTER_HOST='<master_host>', MASTER_USER='<master_user>', MASTER_PASSWORD='<master_password>', MASTER_LOG_FILE='<master_log_file>', MASTER_LOG_POS=<master_log_pos>;
4
Start the slave threads, but instruct it to stop once it reaches the specified log file and position. This ensures consistency.
START SLAVE UNTIL MASTER_LOG_FILE='<master_log_file>', MASTER_LOG_POS=<master_log_pos>;
5
Once the slave stops at the specified point, verify data consistency. If consistent, you can then issue `START SLAVE;` to resume normal replication.
START SLAVE;
3. Investigate and Restart Slave Normally medium
Diagnoses the cause of the slave's stopped state and attempts a normal restart.
1
Connect to your MySQL slave server.
2
Check the slave's status to understand why it stopped.
SHOW SLAVE STATUS\G
3
Carefully examine the output, paying close attention to `Last_Errno`, `Last_Error`, and `Seconds_Behind_Master`. Look for any error messages that indicate a specific problem (e.g., duplicate key, missing table).
4
If the error is transient or a known issue that has been resolved, you can try to restart the slave normally.
START SLAVE;
5
If the slave starts successfully and `Seconds_Behind_Master` decreases, the issue might have been resolved. If it stops again with a similar error, you'll need to address the root cause before attempting to change master or reset.