12

I have added an extra Slave server to an existing MySQL Replication. The Master server and the old Slave server are working fine without any issue, but the newly added server is stoping with the following error:

Last_SQL_Errno: 1032
Last_SQL_Error: Could not execute Update_rows event on table xxx.email_events; Can't find record in 'email_events', Error_code: 1032; handler error HA_ERR_KEY_NOT_FOUND; the event's master log mysqld-bin.000410, end_log_pos 368808733

It will be fine for some hours after repairing.

Questions

  • Can we permanently skip Last_SQL_Errno: 1032?
  • Is there any issue with skipping this error?
adminz
  • 407

5 Answers5

10

You can locate the sql clause code like /usr/bin/mysqlbinlog -v --start-position=142743807 --stop-position=147399325 /data/mysql/data/master-bin.000010 > temp.log

Then compare slave and master database difference according to temp.log on specific pos. Then update slave database.

Then skip that line with mysql -e "stop slave; SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1; start slave;";

3

For people who have this as a one off error, you can try skipping the item:

SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;

START SLAVE;

Steve
  • 31
2

You can set the following in your slave's my.cnf: [mysqld] slave-skip-errors=1032

But as the documentation says: Do not use this option unless you fully understand why you are getting errors. One of the possible reason for this error could be due to “Slave_IO_Running: Yes” but “Slave_SQL_Running: No” that means your Slave IO process is running and retrieving data from Master but couldn’t execute due to Slave_SQL_Running process is stopped. A monitoring tool like Monyog can be used to proactively monitor the replication and alert you to the error or a lag or disconnection between the Master and Slave servers.

1

I had same problem, and I figured out (by console logs of "show slave status\G") that when I was changed some of my replication settings (in my case MASTER_HOST), mysql engine were dropped the setting: MASTER_LOG_POS. And after I altered MASTER_LOG_POS to that wich was in dump imported on slave, all had just work like a charm. Maybe it is not your case, but hope it will help someone.

Dmitry
  • 11
0

You cannot skip the error because, on the replica server, the record will not be available. To fix the issue, follow the steps below:

  1. Retrieve the binlog position using SHOW SLAVE STATUS\G on the replica server, then get the corresponding binlog file from the master server and save it to a text file using the following command:

mysqlbinlog --verbose --base64-output=decode-rows /var/lib/mysql/mysql-bin.000728 > sample.txt

  1. Open the saved text file using less and search for the binlog position. Extract the entire query by searching with a forward slash (/) followed by the binlog position and pressing Enter.

Ex: less sample.txt

  1. Verify whether the table has an ID column. Based on the ID, extract the full INSERT query using mysqldump as follows:
mysqldump --no-create-info --single-transaction -q bodb managedaccscheme --where "Id=2264;"

Replace Id=2264 with the appropriate primary key column condition.

  1. Execute the extracted INSERT query on the replica server by following these steps:

STOP SLAVE; INSERT QUERY; START SLAVE;

This will ensure the missing record is inserted correctly on the replica server.