MySQL并行复制的一个坑
早上巡检数据库,发现一个延迟从库的sql_thread中断了。
Last_SQL_Errno: 1755
Last_SQL_Error: Cannot execute the current event group in the parallel mode. Encountered event Gtid, relay-log name ./oracle-relay-bin.000093, position 152912092 which prevents execution of this event group in parallel mode. Reason: The master event is logically timestamped incorrectly..
检查performance_schema下的replication_applier_status_by_worker表,除了GTID之外也没有更具体的信息:
"root@localhost:mysql3308.sock [(none)]>select * from performance_schema.replication_applier_status_by_worker;
+--------------+-----------+-----------+---------------+------------------------------------------------+-------------------+--------------------+----------------------+
| CHANNEL_NAME | WORKER_ID | THREAD_ID | SERVICE_STATE | LAST_SEEN_TRANSACTION | LAST_ERROR_NUMBER | LAST_ERROR_MESSAGE | LAST_ERROR_TIMESTAMP |
+--------------+-----------+-----------+---------------+------------------------------------------------+-------------------+--------------------+----------------------+
| | 1 | NULL | OFF | 0b961fcc-41c2-11e7-84fd-286ed488c7da:156369774 | 0 | | 0000-00-00 00:00:00 |
| | 2 | NULL | OFF | | 0 | | 0000-00-00 00:00:00 |
| | 3 | NULL | OFF | | 0 | | 0000-00-00 00:00:00 |
| | 4 | NULL | OFF | | 0 | | 0000-00-00 00:00:00 |
| | 5 | NULL | OFF | | 0 | | 0000-00-00 00:00:00 |
| | 6 | NULL | OFF | | 0 | | 0000-00-00 00:00:00 |
| | 7 | NULL | OFF | | 0 | | 0000-00-00 00:00:00 |
| | 8 | NULL | OFF | | 0 | | 0000-00-00 00:00:00 |
+--------------+-----------+-----------+---------------+------------------------------------------------+-------------------+--------------------+----------------------+
既然relay_log的位置信息都有了,那就去日志里看看吧:
解析Binlog文件:
mysqlbinlog -v --base64-output=decode-rows oracle-relay-bin.000093 >1.sql
找到152912092位置点附近的日志:
检查了一下数据库中这个表ID为14816035的数据确实是不存在的。
另外除了这条日志,其它日志的last_committed和sequence_number都为0,last_committed表示事务提交的时候,上次事务提交的编号。last_committed和sequence_number代表的就是所谓的LOGICAL_CLOCK。
猜测如果手动把这条数据插入延迟从库,并且使用注入一个空事务跳过这个GTID的方法重启sql_thread,相信这个错误也能被解决。
但既然带了LOGICAL_CLOCK的事务就会出错,跳过事务的方法很难保证以后不会出错。
注意到这条日志的last_committed是一个异常大的值,且错误信息中有提到The master event is logically timestamped incorrectly。我怀疑是不是并行配置的问题。
从库配置:
"root@localhost:mysql3308.sock [(none)]>show variables like '%para%';
+------------------------+---------------+
| Variable_name | Value |
+------------------------+---------------+
| slave_parallel_type | LOGICAL_CLOCK |
| slave_parallel_workers | 8 |
+------------------------+---------------+
再检查主库配置:
(root@localhost:mysql.sock) [(none)]>show variables like '%para%';
+------------------------+-------+
| Variable_name | Value |
+------------------------+-------+
| slave_parallel_workers | 0 |
+------------------------+-------+
发现主库根本就没有slave_parallel_type这项配置。想起来主库是mysql5.6了。
(root@localhost:mysql.sock) [(none)]>select version();
+------------+
| version() |
+------------+
| 5.6.35-log |
+------------+
那么问题基本上就知道了,主库5.6只支持基于DATABASE的并行复制,而5.7的从库配置成LOGICAL_CLOCK导致了异常。
明白了问题所在,那就好解决了,把从库的slave_parallel_type改为DATABASE,再起sql_thread问题应该就解决了:
"root@localhost:mysql3308.sock [none]>set global slave_parallel_type='DATABASE';
Query OK, 0 rows affected (0.00 sec) "root@localhost:mysql3308.sock [none]>show global variables like '%slave_parallel_type%';
+---------------------+----------+
| Variable_name | Value |
+---------------------+----------+
| slave_parallel_type | DATABASE |
+---------------------+----------+
1 row in set (0.00 sec) "root@localhost:mysql3308.sock [none]>show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: master
Master_User: rep
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: binlog.000104
Read_Master_Log_Pos: 160115307
Relay_Log_File: oracle-relay-bin.000093
Relay_Log_Pos: 152912092
Relay_Master_Log_File: binlog.000100
Slave_IO_Running: Yes
Slave_SQL_Running: No
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 1755
Last_Error: Cannot execute the current event group in the parallel mode. Encountered event Gtid, relay-log name ./oracle-relay-bin.000093, position 152912092 which prevents execution of this event group in parallel mode. Reason: The master event is logically timestamped incorrectly..
Skip_Counter: 0
Exec_Master_Log_Pos: 152911925
Relay_Log_Space: 4455094667
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 1755
Last_SQL_Error: Cannot execute the current event group in the parallel mode. Encountered event Gtid, relay-log name ./oracle-relay-bin.000093, position 152912092 which prevents execution of this event group in parallel mode. Reason: The master event is logically timestamped incorrectly..
Replicate_Ignore_Server_Ids:
Master_Server_Id: 50
Master_UUID: 0b961fcc-41c2-11e7-84fd-286ed488c7da
Master_Info_File: mysql.slave_master_info
SQL_Delay: 3600
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State:
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp: 180716 18:02:56
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set: 0b961fcc-41c2-11e7-84fd-286ed488c7da:111060115-163843604
Executed_Gtid_Set: 0b961fcc-41c2-11e7-84fd-286ed488c7da:1-156369774
Auto_Position: 1
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
1 row in set (0.00 sec) "root@localhost:mysql3308.sock [none]>stop slave sql_thread;
Query OK, 0 rows affected, 1 warning (0.00 sec) "root@localhost:mysql3308.sock [none]>start slave sql_thread;
Query OK, 0 rows affected (0.01 sec) "root@localhost:mysql3308.sock [none]>show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: master
Master_User: rep
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: binlog.000104
Read_Master_Log_Pos: 160161836
Relay_Log_File: oracle-relay-bin.000093
Relay_Log_Pos: 169205552
Relay_Master_Log_File: binlog.000100
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 169205385
Relay_Log_Space: 4455141196
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 5351
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 50
Master_UUID: 0b961fcc-41c2-11e7-84fd-286ed488c7da
Master_Info_File: mysql.slave_master_info
SQL_Delay: 3600
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Waiting for Slave Worker to release partition
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set: 0b961fcc-41c2-11e7-84fd-286ed488c7da:111060115-163843692
Executed_Gtid_Set: 0b961fcc-41c2-11e7-84fd-286ed488c7da:1-156400100
Auto_Position: 1
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
1 row in set (0.00 sec)
打完收工。
转载请注明出处。
本文地址:https://www.cnblogs.com/ajiangg/p/9399892.html
MySQL并行复制的一个坑的更多相关文章
- mysql并行复制降低主从同步延时的思路与启示
一.缘起 mysql主从复制,读写分离是互联网用的非常多的mysql架构,主从复制最令人诟病的地方就是,在数据量较大并发量较大的场景下,主从延时会比较严重. 为什么mysql主从延时这么大? 回答:从 ...
- [转载自阿里丁奇]各版本MySQL并行复制的实现及优缺点
MySQL并行复制已经是老生常谈,笔者从2010年开始就着手处理线上这个问题,刚开始两三年也乐此不疲分享,现在再提这个话题本来是难免"炒冷饭"嫌疑. 最近触发再谈这个话题,是 ...
- MySQL 并行复制演进及 MySQL 8.0 中基于 WriteSet 的优化
MySQL 8.0 可以说是MySQL发展历史上里程碑式的一个版本,包括了多个重大更新,目前 Generally Available 版本已经已经发布,正式版本即将发布,在此将介绍8.0版本中引入的一 ...
- InnoSQL/MySQL并行复制的实现与配置
InnoSQL/MySQL并行复制的实现与配置 http://www.innomysql.net/article/6276.html 并行复制之前的解决方案 InnoSQL在5.5.30-v4版本中支 ...
- 各版本 MySQL 并行复制的实现及优缺点
MySQL并行复制已经是老生常谈,笔者从2010年开始就着手处理线上这个问题,刚开始两三年也乐此不疲分享,现在再提这个话题本来是难免“炒冷饭”嫌疑. 最近触发再谈这个话题,是因为有些同学觉得“5.7的 ...
- 【58沈剑架构系列】mysql并行复制优化思路
一.缘起 mysql主从复制,读写分离是互联网用的非常多的mysql架构,主从复制最令人诟病的地方就是,在数据量较大并发量较大的场景下,主从延时会比较严重. 为什么mysql主从延时这么大? 回答:从 ...
- MySQL并行复制(MTS)原理(完整版)
目录 MySQL 5.6并行复制架构 MySQL 5.7并行复制原理 Master 组提交(group commit) 支持并行复制的GTID slave LOGICAL_CLOCK(由order c ...
- MySQL 并行复制从库发生自动重启分析
并行复制从库发生自动重启分析 背景 半同步复制从库在晚上凌晨2点半发生自动重启,另一个异步复制从库在第二天凌晨3点也发生了自动重启. 分析 版本mysql 5.7.16 mysql> show ...
- MySQL 并行复制(MTS) 从库更新的记录不存在实际却存在
目录 背景 版本 分析 测试 背景 开了并行复制的半同步从库SQL 线程报1032错误,异步复制从库没有报错,偶尔会出现这种 版本 mysql 5.7.16 redhat 6.8 mysql> ...
随机推荐
- xml文件配置新增与读取
xml文件 <?xml version="1.0" encoding="utf-8" ?> <Config> <dbtype> ...
- Go语言远程执行ssh命令简单封装(支持带交互命令)
使用包:golang.org/x/crypto/ssh 以下封装一个发送命令的Cli结构体 type Cli struct { IP string //IP地址 Username string //用 ...
- thinkphp自动验证分析
thinkphp有一个自动验证的方法验证规则如下 array( array(验证字段1,验证规则,错误提示,[验证条件,附加规则,验证时间]), array(验证字段2,验证规则,错误提示,[验证条件 ...
- 业务开发(二)—— Spring框架
0x01.使用枚举类,在MyBatis中 到了mapper.xml文件那里,如Status要与1进行对比,而不是1所对应的枚举字符串. 0x02.分页 Dao获取到的记录数,在Controller层放 ...
- git常用命令总结(资源来自廖雪峰)
自己把命令弄出来方便以后看看,,应该有错的emmmm 原文地址:https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67 ...
- [PHP] 算法-顺时针打印矩阵的PHP实现
1.行数和列数取出来row,col,圈数就是 (较小值-1)/2+1 2.外层循环控制圈数,内层四个for循环,i 3.第一个for循环,从左到右,j=i;j<col-i;j++;j<; ...
- curl模拟ip和来源进行网站采集的实现方法
对于限制了ip和来源的网站,使用正常的采集方式是不行的.这里说我的一种方法吧,使用php的curl类实现模拟ip和来源,可以实现采集限制ip和来源的网站. 1.设置页面限制ip和来源访问比如服务端的s ...
- 34.QT-制作串口助手(并动态检测在线串口,附带源码)
qextserialport-1.2rc库下载链接: http://www.pudn.com/Download/item/id/2298532.html 1.添加源码到工程 将qextserialpo ...
- Spring Boot Docker 实战
Spring Boot Docker 开发环境 开发工具: Intellij IDEA 2018.2.6 springboot: 2.0.6.RELEASE jdk: 1.8.0_192 maven: ...
- Netty实战四之传输
流经网络的数据总是具有相同的类型:字节(网络传输——一个帮助我们抽象底层数据传输机制的概念) Netty为它所有的传输实现提供了一个通用的API,即我们可以将时间花在其他更有成效的事情上. 我们将通过 ...