我对诸如刷新和写入磁盘以及同步到磁盘之类的术语感到困惑。有人能解释一下刷新和写入以及同步到磁盘之间的区别吗,特别是在 MySQL 环境中。
我过去认为它们是相同的操作,但是在阅读各种概念时我感到困惑。
例如。文档中说,对于rpl_semi_sync_source_wait_point变量,如果我将其设置为AFTER_SYNC,则源会先将事务写入 bin 日志和副本,然后将 binlog 同步到磁盘。
AFTER_SYNC (the default): The source writes each transaction to its binary log and the replica, and syncs the binary log to disk.
这句话本身就令人困惑。它先是说source writes each transaction to its binary log and the replica
,然后又说syncs the binary log to disk.
那么在这种情况下究竟发生了什么。在 MySQL 上下文中,刷新、同步和写入磁盘究竟是什么?问题不在于 sync_binlog 或 MySQL 中的任何其他参数。问题在于刷新、同步和写入,以及这些活动何时发生?
当我再次尝试阅读更多内容时,在以下链接中,它解释说,有一个 binlog 缓存、一个页面缓存和一个 fsync 操作。因此,如果我理解正确的话,当发生事务时,缓冲区会变脏,事务的内容将写入 binlog 缓存(在 MySQL 级别),这是每个会话的单独缓存,然后 binlog 缓存将写入页面缓存(在 Linux 级别),然后根据sync_binlog
值,将其刷新/写入/同步到磁盘上的文件。
https://betterprogramming.pub/understanding-mysqls-binlog-4ac8de4d20ee