Last_Error: Slave SQL thread retried transaction 10 time(s) in vain, giving up. Consider raising the
1.版本
1)操作系统
cat /etc/issue
Red Hat Enterprise Linux Server release 5.5 (Tikanga)
Kernel \r on an \m
cat /proc/version
Linux version 2.6.32-504.el6.x86_64 (mockbuild@c6b9.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-11) (GCC) ) #1 SMP Wed Oct 15 04:27:16 UTC 2014
2)mysql数据库版本
mysql --version
mysql Ver 14.14 Distrib 5.6.26, for linux-glibc2.5 (x86_64) using EditLine wrapper
2.问题描述
2.1 发现问题
1)收到生产库的某个从库告警,登录从库 show slave status\G;进行查看,发现如下错误:
Last_Error: Slave SQL thread retried transaction 10 time(s) in vain, giving up. Consider raising the value of the slave_transaction_retries variable.
2)查看从库的errorlog,发现有如下错误:(敏感信息我使用xx替换了)
2016-03-07 16:20:19 8349 [Warning] Slave SQL: Error 'Lock wait timeout exceeded; try restarting transaction' on query. Default database: 'oms_orders'. Query: 'INSERT INTO table1 (xx,xx,xx,xx,xx,xx,xx,xx,xx) VALUES('xx','xx','xx','','x','x','xx','xx','x') ON DUPLICATE KEY UPDATE class_id='xx',parent_class_id='x',class_name='xx',class_desc='',map_id='x',contains_metaclass='0',sort='10000',property='262144',state='0'', Error_code: 1205
##errorlog中如上的错误一共报了10次(因为slave_transaction_retries默认值为10),也就是说在1025错误发生10次以后,从库的Slave_SQL_Running变为NO,并报如上1)中错误。
3. 问题分析
通过从库的errorlog我们可以判断是有什么事物阻塞了 从库的 insert into table1操作,从而导致insert into table1 操作等待加锁超发生超时。根据这个思路跟研发问了一下当时他们在从库上做了什么操作没有。果然他们正好在那个时间点对table1 进行操作。他们的操作可以概括为如下:
create temporary table test1 select * from table1 where;(当然他们的语句复杂很多对同一个表table1进行了多次关联)这个操作执行完需要很长时间。
##ok 分析到现在问题已经很清楚了,是因为研发的create temporary table test1 select * from table1 where ;(会加next-key locks)操作阻塞了 insert into table1 操作。(按照这个思路,在测试环境也重现了该问题)
##注意本篇博客描述的只是该报错的一种可能,该报错也有可能是其他某些原因导致的(没有深入研究)
4. 问题追加
上面从库的报错已经搞清楚了,但是可能细心的朋友有会疑问。怎么在从库上能够建表?
有人可能会说因为从库没有设置read-only为on,还有可能研发用的用户具有super权限。答案呢?,从库已经设置了 read_only,研发使用的也是普通用户没有super权限。 有兴趣的朋友可以试一下在从库上建如下用户,然后使用该用户创建执行 create table和create temporary table
grant select,create,create temporary tables on *.* to 'test1'@'xxxx' identified by 'xxxx';
mysql> create table test1 select * from test;
ERROR 1290 (HY000): The MySQL server is running with the --read-only option so it cannot execute this statement
##我们可以看到设置了read_only为on的情况下,在从库建普通表会报错。
mysql> create temporary table test1 as select * from test;
Query OK, 3 rows affected (0.18 sec)
Records: 3 Duplicates: 0 Warnings: 0
##在read_only为on的情况下,test用户在从库执行create temporary table 成功。
Last_Error: Slave SQL thread retried transaction 10 time(s) in vain, giving up. Consider raising the相关推荐
- Slave SQL thread retried transaction 10 time(s) in vain, giving up. Consider raising the value of t
今天遇到mysql报错: Slave_IO_Running: Yes Slave_SQL_Running: No Replicate_Do_DB: Replicate_Ignore_DB: Repli ...
- Last_Error: Slave SQL thread retried transaction 10 time(s) in vain, giving up导致主从不同步的解决方法
mysql版本:5.6.34 在主库上做了大事务的delete,从库报Last_Error: Slave SQL thread retried transaction 10 time(s) in va ...
- Java开发者写SQL时常犯的10个错误
首页 所有文章 资讯 Web 架构 基础技术 书籍 教程 我要投稿 更多频道 » - 导航条 -首页所有文章资讯Web架构基础技术书籍教程我要投稿更多频道 »- iOS- Python- Androi ...
- 翻译:SQL Server中的索引内部结构:到SQL Server索引级别10的阶梯。
SQL Server中的索引内部结构:到SQL Server索引级别10的阶梯. 大卫•杜兰特2012/01/20 该系列 本文是楼梯系列的一部分:SQL Server索引的阶梯. 索引是数据库设计的 ...
- 数据库:学好SQL必须知道的10个高级概念
今天给大家分享学好SQL必须知道的10个高级概念. 1.常见表表达式(CTEs) 如果您想要查询子查询,那就是CTEs施展身手的时候 - CTEs基本上创建了一个临时表. 使用常用表表达式(CTEs) ...
- 解决mysql主从 The slave IO thread stops because the master has @@GLOBAL.GTID_MODE OFF and this server
mysql主从出现的报错 [报错信息] 初始状态Master和Slave都开启了enforce-gtid-consistency和gtid-mode,然后在Master上把它俩都改动成了off关闭状态 ...
- [ERROR] Slave SQL for channel ‘‘: Could not execute Write_rows event on table xxx.xxx; Duplicate ent
环境:centos7 , MySQL5.7一主一从 背景:从上用xtrabackup物理恢复后,感觉gtid相差不大,直接change master to master_host........ 问题 ...
- Sams Teach Yourself Microsoft SQL Server T-SQL in 10 Minutes
版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章原始出版.作者信息和本声明.否则将追究法律责任. http://blog.csdn.net/topmvp - topmvp Sams Te ...
- [28000][Microsoft][SQL server native client 10.0][SQL server]用户‘sa’登录失败。(18456)
用native远程连接SQL server数据库提示:[28000][Microsoft][SQL server native client 10.0][SQL server]用户'sa'登录失败.( ...
最新文章
- OpenGL鼠标拾取
- 设备自动获取ip DHCP模型 IP为169.254.4.193
- 《深入理解Java虚拟机》笔记6——高效并发
- Django return
- js Ajax跨域访问
- mysql性能优化 硬件优化_mysql性能优化学习笔记(6)数据库配置优化硬件优化...
- oracle实验七 答案,Oracle表的常用查询实验(七)
- Oracle完全手册,Oracle_11g+Oracle Sqldeveloper 安装完全手册(for win 7 64x)
- 阿里程序员双11加班吃什么?
- 3.4 神经网络概述、tensorflow2实现——python实战
- MySQL/MariaDB/Percona数据库升级脚本
- socket和udp
- mysql数据库程序设计实例_mysql数据库编程精华案例347个(知此347个例子,便是高手矣)...
- JEB2.2.7/3.0.0兼容运行
- matlab求解联名方程组带三角函数的,matlab三角函数方程组
- word标题多级编号里的坑
- 2020校招复盘——秋招不易,致敬每一位追梦者(含网易、京东等19家互联网公司后台/Server端面经)
- 静态网络爬虫之Xpath学习
- 计算个人所得税(老版)
- txt改成java没反应_为什么我的TXT文档后戳换成java就打不开呢