mysql5.7:半同步复制增强

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql5.7:半同步复制增强相关的知识,希望对你有一定的参考价值。

mysql5.7.4的文档里有一句话:

http://dev.mysql.com/doc/relnotes/mysql/5.7/en/news-5-7-4.html

Replication: Implemented separate threads for sending and receiving semisynchronous replication acknowledgement signals, so that event streams and ACK streams can be sent and received simultaneously. This should reduce many common delays and thus improve performance with semisynchronous replication in a number of settings.


这句话不太起眼,实际上威力不小,解释一下:

在5.7.4版本的semi sync 框架中,独立出一个线程叫ack_receive ,专门用于接收slave的反馈信息。
这样master上有两个进程独立工作,一个发送binlog到slave,另一个接收slave的反馈。而之前版本,master只有一个进程binlog dump,既负责发送binlog给slave,又负责接收slave反馈。


可以用pstack观察一下mysqld进程:

Thread 52 (Thread 0x7f339d64d700 (LWP 4860)):
#0  0x000000382ac0b98e in [email protected]@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x0000000000eead0a in MYSQL_BIN_LOG::wait_for_update_bin_log(THD*, timespec const*) ()
#2  0x0000000000f0a6fe in Binlog_sender::send_binlog(st_io_cache*, unsigned long long) ()
#3  0x0000000000f0a987 in Binlog_sender::run() ()
#4  0x0000000000f04b81 in mysql_binlog_send(THD*, char*, unsigned long long, Gtid_set*, unsigned int) ()
#5  0x0000000000f076e7 in com_binlog_dump(THD*, char*, unsigned long) ()
#6  0x0000000000d233d6 in dispatch_command(THD*, COM_DATA const*, enum_server_command) ()
#7  0x0000000000d24904 in do_command(THD*) ()
#8  0x0000000000df5b14 in handle_connection ()
#9  0x0000000000f6ff04 in pfs_spawn_thread ()
#10 0x000000382ac079d1 in start_thread () from /lib64/libpthread.so.0
#11 0x000000382a8e8b6d in clone () from /lib64/libc.so.6


Thread 55 (Thread 0x7f336b5fe700 (LWP 4298)):
#0  0x000000382a8e15e3 in select () from /lib64/libc.so.6
#1  0x00007f339c8859fe in Ack_receiver::run() () from /usr/lib64/mysql/plugin/semisync_master.so
#2  0x00007f339c885dc9 in ack_receive_handler () from /usr/lib64/mysql/plugin/semisync_master.so
#3  0x0000000000f6ff04 in pfs_spawn_thread ()
#4  0x000000382ac079d1 in start_thread () from /lib64/libpthread.so.0
#5  0x000000382a8e8b6d in clone () from /lib64/libc.so.6


很明显,我们看到了新的东西:ack_receive,它来自semisync_master.so插件。


实际测试了下,有了这个东西后,半同步架构下的整体TPS有了不小的提升。




本文出自 “记忆碎片” 博客,请务必保留此出处http://weikle.blog.51cto.com/3324327/1792233

以上是关于mysql5.7:半同步复制增强的主要内容,如果未能解决你的问题,请参考以下文章

mysql5.7:半同步复制增强

MySQL 5.7的复制架构,在有异步复制半同步增强半同步MGR等的生产中,该如何选择?

MySQL5.7 半同步复制

MySQL5.7半同步复制环境搭建

mysql5.7.19的半同步复制问题分享

mysql5.7 主从复制简单环境搭建以及开启半同步复制等配置