mysql删除不存在行数据报错_MySQL学习笔记11复制错误处理(二)删除不存在的行的问题...

当在MySQL主库删除某行数据,而在从库中该数据不存在时,会导致从库复制错误。错误信息为'Can't find record in 'test', Error_code: 1032'。解决方法是停止从库,设置`sql_slave_skip_counter=1`跳过错误,然后重新启动从库。在GTID模式下,需重置`mysql.gtid_executed`数据表。" 90723490,5699949,Python变量与作用域详解,"['Python', '编程基础', '作用域', '函数', '闭包']
摘要由CSDN通过智能技术生成

(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;

+-----

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值