mysql5.7 增强半同步
发布日期:2021-11-08 09:37:42 浏览次数:1 分类:技术文章

本文共 2114 字,大约阅读时间需要 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 pthread_cond_timedwait@@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://blog.51cto.com/weikle/1792233

转载地址:https://blog.csdn.net/zhengwei125/article/details/79003431 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:ERROR 1292 (22007): Incorrect datetime value: '0000-00-00 00:00:00'
下一篇:mysql查看当前所有数据库大小

发表评论

最新留言

留言是一种美德,欢迎回访!
[***.207.175.100]2024年04月04日 05时50分42秒