码迷,mamicode.com
首页 > 数据库 > 详细

logical_clock 并发复制mysql5.7解决复制延迟问题

时间:2017-07-21 12:33:26      阅读:253      评论:0      收藏:0      [点我收藏+]

标签:延迟   表示   worker   ati   repos   wait   gic   cut   read   

slave-parallel-type=LOGICAL_CLOCK ##默认database ,logical_clock可能还存在bug,5.7.19修复主从不一致bug

     * Replication: In certain cases, the master could write to

       the binary log a last_committed value which was smaller

       than it should have been. This could cause the slave to

       execute in parallel transactions which should not have

       been, leading to inconsistencies or other errors. (Bug

#84471, Bug #25379659)

MySQL 5.7.19版本修复
 
slave-parallel-workers=4  # 根据并发度设置,如果不需要并发,设置为0,不要设置为1.  1的性能比0差。
以前的sql单线程变成4个线程 Waiting for an event from Coordinator 
 
mysql> show processlist;
+----+-------------+-----------+------+---------+--------+--------------------------------------------------------+------------------+
| Id | User        | Host      | db   | Command | Time   | State                                                  | Info             |
+----+-------------+-----------+------+---------+--------+--------------------------------------------------------+------------------+
| 18 | system user |           | NULL | Connect | 606530 | Slave has read all relay log; waiting for more updates | NULL             |
| 19 | system user |           | NULL | Connect | 606593 | Waiting for an event from Coordinator                  | NULL             |
| 20 | system user |           | NULL | Connect | 838818 | Waiting for an event from Coordinator                  | NULL             |
| 21 | system user |           | NULL | Connect | 841404 | Waiting for an event from Coordinator                  | NULL             |
| 22 | system user |           | NULL | Connect | 841404 | Waiting for an event from Coordinator                  | NULL             |
| 31 | system user |           | NULL | Connect | 862799 | Waiting for master to send event                       | NULL             |
| 40 | root        | localhost | NULL | Query   |      0 | starting                                               | show processlist |
+----+-------------+-----------+------+---------+--------+--------------------------------------------------------+------------------+
7 rows in set (0.06 sec)

并不是严格要求所有同时进入Prepare阶段的事务都在备库并发执行,因此一组提交的事务中可能存在不同的seq no

可以发现较之原来的二进制日志内容多了last_committed和sequence_number,last_committed表示事务提交的时候,

上次事务提交的编号,如果事务具有相同的last_committed,表示这些事务都在一组内,可以进行并行的回放。

#170623 22:27:43 server id 45  end_log_pos 2781491 CRC32 0x1dcd41fa     GTID    last_committed=816      sequence_number=817
#170623 22:27:43 server id 45  end_log_pos 2785022 CRC32 0x2d28e1b7     GTID    last_committed=816      sequence_number=818
master_info_repository=TABLE
relay_log_info_repository=TABLE
relay_log_recovery=ON

logical_clock 并发复制mysql5.7解决复制延迟问题

标签:延迟   表示   worker   ati   repos   wait   gic   cut   read   

原文地址:http://www.cnblogs.com/long2-20160310/p/7216973.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!