书生笔记-Binlog Cache解析

本文详细解析了MySQL中事务binlog event的写入流程,包括binlog cache和临时文件的使用。当事务数据超过binlog_cache_size时,超出部分会存储到临时文件中。在事务提交后,所有数据写入binlog文件并释放资源。binlog_cache_mngr类管理binlog cache和stmt cache,而IO_CACHE子系统负责将事件写入缓存或文件。
摘要由CSDN通过智能技术生成

整个事务的Event在commit的时候才会真正的写入到binlog 文件中,在此之前,这些Event 都放在binlog cache中。

先来看下几个相关参数的定义binlog_cache_sizebinlog_stmt_cache_size

  • The size of the memory buffer to hold changes to the binary log during a transaction. When binary logging is enabled on the server (with the log_bin system variable set to ON), a binary log cache is allocated for each client if the server supports any transactional storage engines. If the data for the transaction exceeds the space in the memory buffer, the excess data is stored in a temporary file. When binary log encryption is active on the server, the memory buffer is not encrypted, but (from MySQL 8.0.17) any temporary file used to hold the binary log cache is encrypted. After each transaction is committed, the binary log cache is reset by clearing the memory buffer and truncating the temporary file if used.

指的是事务的改变,在写到binlog文件之前,存放的内存区域大小。如果数据的大小超过了这个内存大小设置,超出的数据将会被存储到临时文件中。在binlog文件启用加密时,内存buffer区域是不加密的,但是从MySQL8.0.17开始,任何临时文件持有的binlog cache都将会被加密,在每一个事务提交后,binlog cache将会被reset重置

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值