今天遇到线上报错:相关信息如下
这里需要强调一点:
@1
@2
@3
@4
@5
对应的相关表的字段,只要把1,2,3,4,5换成对于表的字段就行了,后面的=xxx,是对应的判断条件,
通过这个就能还原出原来的sql
CREATE TABLE `attention_3e` (
`fromuid` bigint(10) unsigned NOT NULL DEFAULT '0',
`touid` bigint(10) unsigned NOT NULL DEFAULT '0',
`appid` int(10) unsigned NOT NULL DEFAULT '1',
`ip` int(10) unsigned NOT NULL DEFAULT '0',
`addtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`touid`,`fromuid`),
KEY `fro_add_app_ip` (`fromuid`,`addtime`,`appid`,`ip`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8
还原后的sql为:
DELETE FROM `attention`.`attention_3e` WHERE fromuid=59xxx and touid=56xxx and appid=36xxx and ip=20xxx and addtime=14xxx;
这样把delete转换成select
select * from `attention`.`attention_3e` WHERE fromuid=59xxx and touid=56xxx and appid=36xxx and ip=20xxx and addtime=14xxx;
分别在主库和从库上执行
如果主库有,从库没有,那就把从库补上。如果主从都没有就skip
我们在发现的是主从都没有所以在从库上执行skip
stop slave ; set global sql_slave_skip_counter=1;start slave;
然后问题解决了