有一套主从数据库,版本为:percona mysql 5.6.22
每隔一段时间,从库的同步就会停止,报错如下:
Last_Errno: 1205
Last_Error: Slave SQL thread retried transaction 10 time(s) in vain, giving up. Consider raising the value of the slave_transaction_retries variable.
可以通过stop slave/start slave暂时解决该问题,但是过一段时间还会发生,通过error.log和slow.log定位到,每次同步停止时,都在对某张表执行一个sql,sql执行事件达到了20分钟左右,通过日志的信息,定位到该操作是某位同事执行的从数据库中抽取数据到Hbase集群,该抽取过程执行的sql类似下面:
select count(*) from a; 首先确认表a的行数,量级在6百万行左右。
select col1,col2,col3,col4 from a limit 3000000 offset 0;
select col1,col2,col3,col4 from a limit 3000000 offset 3000000;