MYSQL sync_relay_log对I O thread的影响是啥样的
发布时间:2021-12-20 10:42:20 所属栏目:通讯 来源:互联网
导读:MYSQL sync_relay_log对I/O thread的影响是怎样的,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。 我们发现文件描述符fd=50的文件有大量的写入而且频繁的调用fdatasync来同步磁盘,消
MYSQL sync_relay_log对I/O thread的影响是怎样的,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。 我们发现文件描述符fd=50的文件有大量的写入而且频繁的调用fdatasync来同步磁盘,消耗时间非常可观,是MUTEX调用和write 操作的N倍 那么我们就看看文件描述符50到底是什么如下: MYSQL sync_relay_log对I/O thread的影响是怎样的 确实是我们的replay log。 那么问题就确定了,就是因为replay log的写入调用了大量的fdatasync造成的I/O THREAD非常慢,那么是哪一个参数呢? 其实参数就是sync_relay_log,这个参数用来保证relay log的安全,官方文档有如下的图: GTID|sync_relay_log|MASTER_AUTO_POSITION|relay_log_recovery|relay_log_info_repository|Crash type|Recovery guaranteed |Relay log impact OFF 1 Any 1 TABLE Any Yes Lost OFF >1 Any 1 TABLE Server Yes Lost OFF >1 Any 1 Any OS No Lost OFF 1 Any 0 TABLE Server Yes Remains OFF 1 Any 0 TABLE OS No Remains ON Any ON Any Any Any Yes Lost ON 1 OFF 0 TABLE Server Yes Remains ON 1 OFF 0 Any OS No Remains 我们可以看到如果不设置sync_relay_log那么有可能造成relay log丢失的风险,其实上面的分析已经看到就是调用fdatasync来完成这个功能,但是 这样的代价基本是不可接受的。官方文档有如下说明: It is important to note the impact of sync_relay_log=1, which requires a write of to the relay log per transaction. Although this setting is the most resilient to an unexpected halt, with at most one unwritten transaction being lost, it also has the potential to greatly increase the load on storage. Without sync_relay_log=1, the effect of an unexpected halt depends on how the relay log is handled by the operating system. A value of 1 is the safest choice because in the event of a crash you lose at most one event from the relay log. However, it is also the slowest choice (unless the disk has a battery-backed cache, which makes synchronization very fast). 每次事物都会调用fdatasync,代价太高。所以没办法修改了sync_relay_log的设置,默认值是10000,也就是10000个事物进行一次 fdatasync。 关于MYSQL sync_relay_log对I/O thread的影响是怎样的问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注亿速云行业资讯频道了解更多相关知识。 (编辑:92站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
站长推荐
热点阅读