MySQL Replication--开启GTID模式下匿名事务异常
错误环境:
OS: CentOS release 6.5 (Final)
MySQL: MySQL 5.7.19
主从参数配置:
master_info_repository = TABLE
relay_log_info_repository = TABLE
gtid_mode = on
enforce-gtid-consistency = true
log_slave_updates = 1
slave-parallel-workers = 8
slave-parallel-type = LOGICAL_CLOCK
slave_preserve_commit_order = 0
错误描述:
从库SQL进程异常停止(从库在此前刚因内存异常重启),报错内容为:
Last_Errno:
Last_Error: Error executing row event: '@@SESSION.GTID_NEXT cannot be set to ANONYMOUS when @@GLOBAL.GTID_MODE = ON.'
出库执行位点:
Relay_Master_Log_File: mysql-bin.001204
Exec_Master_Log_Pos: 52454628
Executed_Gtid_Set: 6b5be2cf-b1ad-11e7-aeb2-246e965aa709:1432389-825991260
按照位点信息去主库上解析binlog
/export/servers/mysql/bin/mysqlbinlog -vvv /export/data/mysql/data/mysql-bin.001204 --start_position=52454628 |more
输出内容为:
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
# at 4
#190518 1:05:08 server id 60863 end_log_pos 123 CRC32 0x0545d99b Start: binlog v 4, server v 5.7.19-log created 190518 1:05:08
BINLOG '
xOneXA+/7QAAdwAAAHsAAAAAAAQANS43LjE5LWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAEzgNAAgAEgAEBAQEEgAAXwAEGggAAAAICAgCAAAACgoKKioAEjQA
AZvZRQU=
'/*!*/;
# at 52454628
#190518 2:56:10 server id 60863 end_log_pos 52455702 CRC32 0x24c5219e Update_rows: table id 27578 flags: STMT_END_F BINLOG '
ygPfXB+/7QAAMgQAABZpIAMAALprAAAAAAEAAgBX/////////////////////////////6ABAyBw
D8B8ALyAPfUdAAAAAAABMQwxMDAwMDAwMTc1NTmMAOWuieWwlOmbhSBBTkVSWUEg5pel5byP5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AAAAAAAIAAAAAAAACAAAAAAAAAATADNjUxATMAgAAAAp4AAIAAAAJdAACAAAACWAAAATAB
MAEwAAEwPgBqZnMvdDMwMzgyLzIzOC8yMjAzMzczNTUvMjgzMDMyLzM2MmM4NmI3LzViZWJiMjk3
TmUxYTkyNmZjLmpwZwEAMSOx2cNqAQAAA+eusQAAgAAAAAAAAIAAAAAAAACeIcUk
'/*!*/;
### Row event for unknown table #27578# at 52455702
#190518 2:56:10 server id 60863 end_log_pos 52455733 CRC32 0xb829837d Xid = 8647697161
COMMIT/*!*/;
# at 52455733
#190518 2:56:10 server id 60863 end_log_pos 52455798 CRC32 0x02c73826 GTID last_committed=21489 sequence_number=21490 -rbr_only=yes
/*!50718 SET TRANSACTION ISOLATION LEVEL READ COMMITTED*//*!*/;
SET @@SESSION.GTID_NEXT= '6b5be2cf-b1ad-11e7-aeb2-246e965aa709:825990109'/*!*/;
# at 52455798
#190518 2:56:10 server id 60863 end_log_pos 52455871 CRC32 0x1863b7ae Query thread_id=7254910 exec_time=0 error_c
ode=0
SET TIMESTAMP=1558119370/*!*/;
SET @@session.pseudo_thread_id=7254910/*!*/;
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
SET @@session.sql_mode=1411383296/*!*/;
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
/*!\C utf8 *//*!*/;
SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=33/*!*/;
SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
BEGIN
/*!*/;
# at 52455871
网上关于错误“Row event for unknown table”的资料较少,查到资料解释大意是在建立table map信息丢失导致。
参考链接:
https://bugs.mysql.com/bug.php?id=60964
https://www.jianshu.com/p/4e28f09b3ce5
从上面的解析结果发现,该事务设置GTID_NEXT,难道真的是匿名事务?
通过指定时间段方式来解析:
/export/servers/mysql/bin/mysqlbinlog -vvv /export/data/mysql/data/mysql-bin.001204 --start_datetime='2019-05-18 2:56:09' --stop_datetime='2019-05-18 2:56:11'
解析结果包含如下信息:
# at 52454142
#190518 2:56:10 server id 60863 end_log_pos 52454173 CRC32 0xb0e1832b Xid = 8647697160
COMMIT/*!*/;
### GTID为6b5be2cf-b1ad-11e7-aeb2-246e965aa709:825990107的事务提交
# at 52454173
#190518 2:56:10 server id 60863 end_log_pos 52454238 CRC32 0x83d1552a GTID last_committed=21486 sequence_number=21489 rbr_only=yes
/*!50718 SET TRANSACTION ISOLATION LEVEL READ COMMITTED*//*!*/;
### GTID为6b5be2cf-b1ad-11e7-aeb2-246e965aa709:825990108的事务开始
SET @@SESSION.GTID_NEXT= '6b5be2cf-b1ad-11e7-aeb2-246e965aa709:825990108'/*!*/;
# at 52454238
#190518 2:56:10 server id 60863 end_log_pos 52454314 CRC32 0xb78b3241 Query thread_id=7172612 exec_time=0 error_code=0
SET TIMESTAMP=1558119370/*!*/;
BEGIN
/*!*/;
# at 52454314
#190518 2:56:10 server id 60863 end_log_pos 52454628 CRC32 0x643ab683 Table_map: `report`.`bs_itembase` mapped to number 27578
# at 52454628
#190518 2:56:10 server id 60863 end_log_pos 52455702 CRC32 0x24c5219e Update_rows: table id 27578 flags: STMT_END_F BINLOG '
ygPfXBO/7QAAOgEAAORkIAMAALprAAAAAAEABnJlcG9ydAALYnNfaXRlbWJhc2UAVwgPDw8PD/b2
Dw8PDw8PDw8PDw8PDw8PDw8PDw8PDxIRDw8PDw8PD/YPDw8PDw8PD/YP9vb29g8P9g8PDw8PDw8P
Afb29g8PDwEPDw8PDw8PDwgPARD29qKWAFoA3AUDAB4ADwQPBB4AAwCWACwBlgAAAwMAAwAeAB4A
AwADAAMAAwADAJYAAwBYAgMAAwCWAAADAAB4ADwAPABYAgMAAwB4AA8EeAB4AHgAeAADAAMAAwAD
AA8EAwAPBA8EDwQPBB4AHgAPBAMAAwADAB4AHgAeADwAPAAPBA8EDwQDAAMAAwADAHgA3AVYAiwB
WALcBVgCPAABAA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wMTc1NTkBMAEwAJmiB0vEXN8DygMzMDERZ29vZHNJbmZvRG93bmxvYWQRZ29vZHNJbmZv
RG93bmxvYWQMADEwMDAwMDAxNzU1OYAAAAAAAAABMAEwATABMIAAAAAAAAABMIAAAAAAAACAAAAA
AAAAgAAAAAAAAIAAAAAAAACAAAAAAAAAATADNjUxATMAgAAAAp4AAIAAAAJdAACAAAACWAAAATAB
MAEwAAEwPgBqZnMvdDMwMzgyLzIzOC8yMjAzMzczNTUvMjgzMDMyLzM2MmM4NmI3LzViZWJiMjk3
TmUxYTkyNmZjLmpwZwEAMSOx2cNqAQAAA+eusQAAgAAAAAAAAIAAAAAAAACeIcUk
'/*!*/;
### UPDATE `report`.`xxxx`
### WHERE
### 更新语句... # at 52455702
#190518 2:56:10 server id 60863 end_log_pos 52455733 CRC32 0xb829837d Xid = 8647697161
COMMIT/*!*/;
### GTID为6b5be2cf-b1ad-11e7-aeb2-246e965aa709:825990108的事务提交
# at 52455733
#190518 2:56:10 server id 60863 end_log_pos 52455798 CRC32 0x02c73826 GTID last_committed=21489 sequence_number=21490 rbr_only=yes
/*!50718 SET TRANSACTION ISOLATION LEVEL READ COMMITTED*//*!*/;
### GTID为6b5be2cf-b1ad-11e7-aeb2-246e965aa709:825990109的事务开始
SET @@SESSION.GTID_NEXT= '6b5be2cf-b1ad-11e7-aeb2-246e965aa709:825990109'/*!*/;
# at 52455798
#190518 2:56:10 server id 60863 end_log_pos 52455871 CRC32 0x1863b7ae Query thread_id=7254910 exec_time=0 error_code=0
SET TIMESTAMP=1558119370/*!*/;
SET @@session.sql_mode=1411383296/*!*/;
BEGIN
/*!*/;
# at 52455871
#190518 2:56:10 server id 60863 end_log_pos 52455941 CRC32 0xb9e2e221 Table_map: `dcomb`.`snapshot_position` mapped to number 30731
# at 52455941
#190518 2:56:10 server id 60863 end_log_pos 52456099 CRC32 0xea181383 Update_rows: table id 30731 flags: STMT_END_F
从上面解析内容可以发现事务中包含有GTID信息,但由于从库复制使用基于位点方式搭建,且从库开启多线程复制,因此Exec_Master_Log_Pos=52454628信息记录并不准确,而从该位置点开始应用BINLOG,没有执行该位点上面的内容(标黄部分):
#190518 2:56:10 server id 60863 end_log_pos 52454238 CRC32 0x83d1552a GTID last_committed=21486 sequence_number=21489 rbr_only=yes
/*!50718 SET TRANSACTION ISOLATION LEVEL READ COMMITTED*//*!*/;
### GTID为6b5be2cf-b1ad-11e7-aeb2-246e965aa709:825990108的事务开始
SET @@SESSION.GTID_NEXT= '6b5be2cf-b1ad-11e7-aeb2-246e965aa709:825990108'/*!*/;
# at 52454238
#190518 2:56:10 server id 60863 end_log_pos 52454314 CRC32 0xb78b3241 Query thread_id=7172612 exec_time=0 error_code=0
SET TIMESTAMP=1558119370/*!*/;
BEGIN
/*!*/;
# at 52454314
#190518 2:56:10 server id 60863 end_log_pos 52454628 CRC32 0x643ab683 Table_map: `report`.`bs_itembase` mapped to number 27578
# at 52454628
#190518 2:56:10 server id 60863 end_log_pos 52455702 CRC32 0x24c5219e Update_rows: table id 27578 flags: STMT_END_F
当执行到COMMIT时,由于没有设置GTID_NEXT,因此MySQL认为该事务未匿名事务,SQL线程异常停止。
上面的情况是跳过"SET @@SESSION.GTID_NEXT" 和"BEGIN"两部分,而如果只跳过"SET @@SESSION.GTID_NEXT",则执行BEGIN时,会报如下错误:
Last_Errno: 1782
Last_Error: Error '@@SESSION.GTID_NEXT cannot be set to ANONYMOUS when @@GLOBAL.GTID_MODE = ON.' on query. Default database: ''. Query: 'BEGIN'
位于该错误位点的GTID为“6b5be2cf-b1ad-11e7-aeb2-246e965aa709:825990108”,而从库执行过的GTID为“6b5be2cf-b1ad-11e7-aeb2-246e965aa709:1432389-825991260”,由于缺少GTID_NEXT标识事务,从库无法判定该事务是否已在从库上执行,也就无法自动跳过该事务。
由于参数relay_log_recovery默认值为OFF,从库服务器上未明确设置参数relay_log_recovery=ON,还需验证该参数对上述异常的影响,未完待续。
MySQL Replication--开启GTID模式下匿名事务异常的更多相关文章
- 关于GTID模式下备份时 --set-gtid-purged=OFF 参数的实验【转】
刚刚听了吴老师是复制章节课程,对于GTID模式下备份数据--set-gtid-purged=OFF 参数有些不理解,于是乎做了实验,加深理解,得出些结论,如有错漏请批评指正! 部分备份: [root@ ...
- MySQL主从复制之GTID模式介绍
GreatSQL社区原创内容未经授权不得随意使用,转载请联系小编并注明来源. GTID概述 MySQL5.6 在原有主从复制的基础上增加了一个新的复制方式,即基于GTID的复制方式,它由UUID和事务 ...
- MySQL 主从复制开启 GTID
GTID (Golobal Transaction ID) 是对于一个已提交事务的唯一编号,并且是一个全局(主从复制)唯一的编号. GTID 复制和传统复制的区别:在启动主从复制时,不需要指定 bin ...
- RR模式下的事务隔离
<pre name="code" class="html">mysql> select * from t100; Session 2: +-- ...
- jlink RTT 打印 BUG , FreeRTOS 在开启 tickless 模式下 无法使用的问题
一开始我以为是 jlink 的问题,后面发现是 tickless 模式搞鬼 tickless 模式下 ,内核 会 根据任务需求,会停止工作,这个时候 jlink rtt 打印就会失效!!! 不过 NR ...
- ASM:《X86汇编语言-从实模式到保护模式》第17章:保护模式下中断和异常的处理与抢占式多任务
★PART1:中断和异常概述 1. 中断(Interrupt) 中断包括硬件中断和软中断.硬件中断是由外围设备发出的中断信号引发的,以请求处理器提供服务.当I/O接口发出中断请求的时候,会被像8259 ...
- MySQL MGR 单主模式下master角色切换规则
MGR单主模式,master节点可读可写,其余节点都是只读.当配置MGR为单主模式,非master节点自动开启super_read_only 当可读可写的节点异常宕机,会进行怎样的切换?在选择新的可写 ...
- mysql在命令行模式下创建数据库时要显式指定字符集
create database db1 DEFAULT CHARACTER SET utf8 COLLATE utf8_chinese_ci;
- MySQL 在 Kubernetes IPVS 模式下引发的 TCP 超时问题
文章转载自:https://mp.weixin.qq.com/s/XQ2SlCYxvXPY0rRRO-CURA
随机推荐
- Oracle中如何修改已存在数据的列名的数据类型
在oracle中,如何修改已存在数据列名的数据类型 一般人直接在表结构设计这里修改,这里只适合修改列没有数据,可修改 那么,如何这个列是有数据,是怎么修改的呢? 直接修改会Oracle错误 第一步:先 ...
- Node add Test1
root_group->addChild(node22); osg::Vec3f vec3f1 = node22->getBound().center(); osg::NodePathLi ...
- Qt开发经验小技巧11-20
获取类的属性 const QMetaObject *metaobject = object->metaObject(); int count = metaobject->propertyC ...
- matlab学习笔记8 基本绘图命令-基本绘图操作
一起来学matlab-matlab学习笔记8 基本绘图命令_2基本绘图操作 觉得有用的话,欢迎一起讨论相互学习~Follow Me 参考书籍 <matlab 程序设计与综合应用>张德丰等著 ...
- Spring MVC -- Spring MVC入门
本篇博客首先介绍Spring MVC的优点,然后介绍Spring MVC的基本组件,包括DispatcherServlet,并学习如何开发一个“传统风格”的控制器,这是在Spring 2.5版本之前开 ...
- Jenkins - 插件管理
1 - Jenkins插件 Jenkins通过插件来增强功能,可以集成不同的构建工具.云平台.分析和发布工具等,从而满足不同组织或用户的需求. Jenkins 提供了不同的的方法来安装插件(需要不同级 ...
- 【C/C++开发】多线程编程中的join函数
多线程编程中的join函数 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 # coding: utf-8 # 测试多线程中join的 ...
- kindeditor——开源的HTML可视化编辑器
官网:http://kindeditor.net/demo.php 主要操作文档:http://kindeditor.net/docs/option.html
- QT QML与C++混搭
"那些杀不死我的必使我更加强大"----尼采 QML与C++混合编程就是使用QML高效便捷地构建UI,而C++则用来实现业务逻辑和复杂算法. ML访问C++Qt集成了QML引擎和Q ...
- Mac打开原生NTFS功能
一.在 terminal 里输入 diskutil list 查看 U 盘的 NAME diskutil list 二.执行以下命令,输入密码 sudo nano /etc/fstab 三.把U盘信息 ...