好久没写博客了,都长草了。新业务上了5.7没遇到什么问题,虽然没遇到什么问题,但不代表没有问题,我有个习惯就是没事就喜欢逛逛percona的Blog,于是看到目前最新GA版本5.7.17的2个bug,于是就搭建环境进行bug复现。目前知道的2个bug如下:

1. slave_parallel_workers > 0,也就是开启了多线程复制的时候如果有延时,那么Seconds_Behind_Master一直是0,不会变化,虽然这个参数不准确,但也是一个衡量指标。准确的复制延时判断的请看我前面的文章:主从复制延时判断

2. super_read_only开启的时候mysql库中的gtid_executed表会压缩失败,至于这个表是干嘛的请参考文章:MySQL 5.7中新增的表gtid_executed,看看是否解决了你的痛点,原文作者是姜承尧,但原作者的连接打不开了。

环境:5.7.17, 1主2从,下面进行第一个bug的复现,其中一个从库是普通复制,也就是没开启多线程复制,另外一个从库开启多线程复制。

首先用sysbench写入100w数据,然后在主库进行delete操作,模拟延时,然后查看区别。

sysbench --test=oltp --oltp-table-size=1000000 --oltp-read-only=off --init-rng=on --num-threads=16 --max-requests=0 --oltp-dist-type=uniform --max-time=1800 --mysql-user=root --mysql-socket=/data/mysql/3306/mysqltmp/mysql.sock --mysql-password=123 --db-driver=mysql --mysql-table-engine=innodb --oltp-test-mode=complex prepare 

普通复制:

mysql> show variables like '%parallel%';
+------------------------+----------+
| Variable_name          | Value    |
+------------------------+----------+
| slave_parallel_type    | DATABASE |
| slave_parallel_workers | 0        |
+------------------------+----------+
2 rows in set (0.00 sec)mysql> 

多线程复制:

mysql> show variables like '%parallel%';
+------------------------+---------------+
| Variable_name          | Value         |
+------------------------+---------------+
| slave_parallel_type    | LOGICAL_CLOCK |
| slave_parallel_workers | 8             |
+------------------------+---------------+
2 rows in set (0.02 sec)

准备查看复制延时脚本:

for i in {1..1000};
do(mysql -uroot -p123 -h 192.168.0.20 -e "SHOW SLAVE STATUS\G" | grep "Seconds_Behind_Master" | awk '{print "slave_1_not-multi-threaded-repl: " $2}' &sleep 0.1 ;mysql -uroot -p123 -h 192.168.0.30 -e "SHOW SLAVE STATUS\G" | grep "Seconds_Behind_Master" | awk '{print "slave_2_multi-threaded-repl: " $2}' &);sleep 1;
done

让这个脚本跑起来,然后在主库删除数据,看复制延时的情况。然后在主库删除数据:

delete from sbtest where id>100;

运行脚本,查看复制延时情况,输出如下,可以看到开启了多线程复制的Seconds_Behind_Master一直为0,不会变化,而普通复制则显示延时了。

[root@dbserver-yayun-04 ~]# sh a.sh
mysql: [Warning] Using a password on the command line interface can be insecure.
slave_1_not-multi-threaded-repl: 103
mysql: [Warning] Using a password on the command line interface can be insecure.
slave_2_multi-threaded-repl: 0
mysql: [Warning] Using a password on the command line interface can be insecure.
slave_1_not-multi-threaded-repl: 104
mysql: [Warning] Using a password on the command line interface can be insecure.
slave_2_multi-threaded-repl: 0
mysql: [Warning] Using a password on the command line interface can be insecure.
slave_1_not-multi-threaded-repl: 105
mysql: [Warning] Using a password on the command line interface can be insecure.
slave_2_multi-threaded-repl: 0
mysql: [Warning] Using a password on the command line interface can be insecure.
mysql: [Warning] Using a password on the command line interface can be insecure.
slave_1_not-multi-threaded-repl: 106
slave_2_multi-threaded-repl: 0

Percona给的解决方法是:

SELECT PROCESSLIST_TIME FROM performance_schema.threads WHERE NAME = 'thread/sql/slave_worker' AND (PROCESSLIST_STATE IS NULL  or PROCESSLIST_STATE != 'Waiting for an event from Coordinator') ORDER BY PROCESSLIST_TIME DESC LIMIT 1;

下面进行super_read_only开启以后触发bug的复现:

1. 其中一个从库设置gtid_executed_compression_period=1,用来控制每执行多少个事务,对此表进行压缩,默认值为1000

2. super_read_only开启,超级用户都无法更改从库的数据。

3. 关闭log_slave_updates,如果开启,gtid_executed表不会实时变更,也不会压缩。(percona博客中开启了log_slave_updates也触发了bug,我认为是博客中有错误)

mysql> show variables like '%gtid_ex%';
+----------------------------------+-------+
| Variable_name                    | Value |
+----------------------------------+-------+
| gtid_executed_compression_period | 1     |
+----------------------------------+-------+
1 row in set (0.01 sec)mysql> show variables like '%log_slave_updates%';
+-------------------+-------+
| Variable_name     | Value |
+-------------------+-------+
| log_slave_updates | OFF   |
+-------------------+-------+
1 row in set (0.00 sec)mysql> show variables like '%super%';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| super_read_only | ON    |
+-----------------+-------+
1 row in set (0.00 sec)mysql> 

下面在主库运行sysbench进行压测,产生事务。

sysbench --test=oltp --oltp-table-size=100000 --oltp-read-only=off --init-rng=on --num-threads=16 --max-requests=0 --oltp-dist-type=uniform --max-time=1800 --mysql-user=root --mysql-socket=/data/mysql/3306/mysqltmp/mysql.sock --mysql-password=123 --db-driver=mysql --mysql-table-engine=innodb --oltp-test-mode=complex run

查看从库:

mysql> select count(*) from gtid_executed;
+----------+
| count(*) |
+----------+
|       93 |
+----------+
1 row in set (0.44 sec)mysql> select count(*) from gtid_executed;
+----------+
| count(*) |
+----------+
|      113 |
+----------+
1 row in set (0.66 sec)mysql> 

可以发现并没有压缩,一直在增加。
执行show engine innodb status可以看到有线程在压缩表的,但是没成功,在回滚

---TRANSACTION 10909611, ACTIVE 2 sec rollback
mysql tables in use 1, locked 1
ROLLING BACK 4 lock struct(s), heap size 1136, 316 row lock(s)
MySQL thread id 1, OS thread handle 140435435284224, query id 0 Compressing gtid_executed table

查看INNODB_TRX表,也能发现有事务在回滚。

mysql> select trx_id,trx_state,trx_operation_state,trx_isolation_level from information_schema.INNODB_TRX;
+-----------------+--------------+---------------------+---------------------+
| trx_id          | trx_state    | trx_operation_state | trx_isolation_level |
+-----------------+--------------+---------------------+---------------------+
| 10919604        | ROLLING BACK | rollback            | REPEATABLE READ     |
| 421910840085200 | RUNNING      | starting index read | REPEATABLE READ     |
+-----------------+--------------+---------------------+---------------------+
2 rows in set (0.00 sec)

看见现在表已经有很多记录了:

mysql> select count(*) from gtid_executed;
+----------+
| count(*) |
+----------+
|     2448 |
+----------+
1 row in set (0.00 sec)mysql> 

关闭super_read_only

mysql> set global super_read_only=0;
Query OK, 0 rows affected (0.00 sec)mysql> select count(*) from gtid_executed;
+----------+
| count(*) |
+----------+
|        2 |
+----------+
1 row in set (0.07 sec)mysql> select count(*) from gtid_executed;
+----------+
| count(*) |
+----------+
|        2 |
+----------+
1 row in set (0.00 sec)mysql> 

马上恢复正常了。

参考文章:

https://www.percona.com/blog/2017/02/08/mysql-super_read_only-bugs/
https://www.percona.com/blog/2017/01/27/wrong-seconds_behind_master-with-slave_parallel_workers-0/
http://keithlan.github.io/2017/02/15/gtid_practice/?utm_source=tuicool&utm_medium=referral

转载于:https://www.cnblogs.com/gomysql/p/6509237.html

MySQL 5.7最新版本的2个bug相关推荐

  1. mysql开发规范最新版本_MYSQL 开发规范

    数据库命名规范 所有数据库对象表名必须小写 (mybook_db) 命名要做到见名知意,不能使用mysql保留关键字 临时表 tmp_ 开头,备份表以 bak_ 开头 都以时间戳结尾 所有存储相同数据 ...

  2. MySQL 5.7最新版本下载与安装教程

    目录 一.下载 二.配置环境变量 三.cmd安装 一.下载 官网地址:MySQL 二.配置环境变量 此电脑→属性→高级系统设置→环境变量→系统变量→Path 点击新建,复制下载好的mysql所在文件夹 ...

  3. 【Defects4J一气呵成】在VMWare上新建Ubuntu 18.04 虚拟机,并安装JDK 8,复现Defects4J最新版本(818个bug,version 2.0.0)

    文章目录 前言 1.1 创建Ubuntu虚拟机 1.1.1下载VMWare 1.1.2 下载Ubuntu系统镜像 1.1.3 新建虚拟机 1.1.4 更换apt源 1.1.5 [可选]使用xshell ...

  4. 安装 MySQL 最新版本

    目前我这个时间点, MySQL 的最新版本是 8.0.27 文章目录 1.下载 MySQL 2.安装 MySQL 3.配置环境变量 1.下载 MySQL 下载地址:https://dev.mysql. ...

  5. 如何从官网下载MySQL最新版本的安装包?

    如何从官网下载MySQL最新版本的安装包? 下载地址:http://www.mysql.com/downloads/ 1.选择下载社区版本 MySQL Community Edition (GPL) ...

  6. MySQL的安装(最新版本)(二)

    为了大家能清晰的理解内容 这里附上之前的一篇文章 MySQL的下载(最新版本)(一)_大数据的小数据孩儿的博客-CSDN博客本人该学期下载了太多软件,涉及到各种兼容性问题,还有配置问题,导致好多软件在 ...

  7. 【数据库MySQL】2021最新官网下载及查看MySQL版本步骤教程

    下载教程 最新版本下载 历史版本查看及下载 查询MySQL版本号 进阶:[MySQL安装及配置](https://blog.csdn.net/TheChany/article/details/1209 ...

  8. MySQL最新版本安装教程(Windows和Ubuntu)

    MySQL官方安装教程 官方安装教程,各种系统的安装都有:https://dev.mysql.com/doc/refman/8.0/en/installing.html MySQL Community ...

  9. linux下mysql6.0 yum安装,Yum安装最新版本MySQL的方法

    摘要 腾兴网为您分享:Yum安装最新版本MySQL的方法,桌面时钟,翼拍照,小熊到家,梦想旅行等软件知识,以及qq浏览器tv版,广告音乐制作,票友网,雪兔社区,搬运帮,is智慧平台登录,gpuinfo ...

最新文章

  1. 设置普通用户加入域配额
  2. RHEL 6上KVM的安装配置及使用-将物理接口桥接到桥接器
  3. qt 文件 时间 倒序排列_win7电脑敬业签便签软件分类标签里的内容如何按提醒时间排列?...
  4. MapReduce源码分析总结
  5. java基础面试题整理(BAT)
  6. python中包含的标准数据类型_Python数据类型基础
  7. google搜索url参数总结
  8. 解决formview遍历控件的问题
  9. 关于VS2019调试问题:进程已退出,代码为-1073741819(已解决)
  10. python获取windows窗口的内容_Python实现遍历windows所有窗口并输出窗口标题的方法...
  11. 制作透明背景图片,按钮
  12. 【Shawn-LeetCode】Two Sum
  13. eCommerce电子商务业务领域常见的一些术语
  14. android 蓝牙电话号码,Android拨打电话和蓝牙状态监听
  15. 高中英语完形填空同义词90%选项
  16. 2021年中式烹调师(中级)考试题库及中式烹调师(中级)报名考试
  17. c3p0-config.xml配置文件的那些事
  18. RDMA技术详解——DMA和RDMA概念
  19. FileUploadException: Header section has more than 10240 bytes (maybe it is not properly terminated)]
  20. 移动光猫调整桥接模式

热门文章

  1. python手机版编程-可以使用手机编程实现python吗
  2. python写一个游戏多少代码-使用50行Python代码从零开始实现一个AI平衡小游戏
  3. python论坛哪些好-好的python论坛
  4. python读取excel画散点图-matplotlib两种画散点图的方式
  5. 电脑安装python为什么不能用-python安装后不能运行怎么办
  6. python培训好学吗-开平北大青鸟:Python培训怎么选?Python好学吗?
  7. python好找工作吗2017-2018年七大工作机会最多的编程语言和技术!
  8. python贴吧发帖脚本-分享用Python写的99收抢单小脚本,仅供学习
  9. python用途与前景-2019年Python就业及发展前景如何 看完你就清晰了
  10. 方差、标准差、均方差、均方误差理解