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 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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章