Overview
The error message Got fatal error 1236 from master when reading data from binary log:
typically indicates that the replication slave is trying to read from a position in the master’s binary log that doesn’t exist.
The detailed error is as follow:
[mysql] Last_IO_Errno: 1236
[mysql] Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'Client requested master to start replication from impossible position; the first event 'mysqld-bin.000041' at 29123876, the last event read from 'mysqld-bin.000041' at 4, the last byte read from 'mysqld-bin.000041' at 4.'
Explanation
Typically this can happen for several reasons:
- The binary log has been purged: The position the slave is trying to read from has been removed because the binary logs have been purged on the master.
- Mismatch between master and slave log positions: The slave might be trying to read from a position that is beyond the end of the current binary log on the master.
- Master and slave desynchronization: There might have been a reset or reconfiguration on the master that invalidated the current binary log position the slave is trying to read from.
To resolve this issue, you can follow these steps:
Check the Current Master Binary Log Position
On the master server, check the current binary log file and position:
SHOW MASTER STATUS;
This will give you the current binary log file and position.
Correct the Slave’s Log File and Position
On the slave server, stop the slave:
STOP SLAVE;
Then, set the correct log file and position from the master’s current status:
CHANGE MASTER TO MASTER_LOG_FILE='your_log_file', MASTER_LOG_POS=your_log_position;
Replace
your_log_file
andyour_log_position
with the values obtained from the master.
Start the Slave
START SLAVE;
Check the Slave Status
SHOW SLAVE STATUS\G;
Look for any errors in the output.
Additional Troubleshooting
If the above steps don’t resolve the issue, you may need to take additional actions such as:
- Re-sync the Slave: If the data on the slave is out of sync, consider re-syncing the slave with the master. This can be done by taking a fresh backup from the master and restoring it on the slave.
- Check for Configuration Issues: Ensure that the server-id is unique for each server and that the replication user has the necessary permissions.
- Check Network Issues: Ensure that there are no network issues between the master and the slave that could be causing communication problems.
Conclusion
By following these steps, you should be able to resolve the replication error and get the replication process back on track.