(1)问题情况
在master上删除某个数据表的某一行,而该行在slave上并不存在,则slave上的复制过程会出错。
MySQL的log文件中发现如下错误信息:
2017-08-15T04:52:19.529509Z 13 [ERROR] Slave SQL for channel ‘‘: Could not execute Delete_rows event on table test.test; Can‘t find record in ‘test‘, Error_code: 1032; handler error HA_ERR_END_OF_FILE; the event‘s master log mysql-bin.000007, end_log_pos 1958, Error_code: 1032
2017-08-15T04:52:19.529575Z 13 [Warning] Slave: Can‘t find record in ‘test‘ Error_code: 1032
2017-08-15T04:52:19.529588Z 13 [ERROR] Error running query, slave SQL thread aborted. Fix the problem, and restart the slave SQL thread with "SLAVE START". We stopped at log ‘mysql-bin.000007‘ position 1732
(2)重现问题场景。
(a)在slave上删除数据表test的某一行数据。
mysql> delete from test where name2=‘001‘;
Query OK, 1 row affected (0.07 sec)
mysql> select * from test;
+-------+
| name2 |
+-------+
| 002 |
| 003 |
+-------+
2 rows in set (0.00 sec)
(b)在master上删除数据表test的该行数据。
mysql> select * from test;
+-------+
| name2 |
+-------+
| 001 |
| 002 |
| 003 |
+-------+
3 rows in set (0.00 sec)
mysql> delete from test where name2=‘001‘;
Query OK, 1 row affected (0.02 sec)
mysql> select * from test;
+-----