innodb: 两个事务在binlog文件中不会交叉


这是因为innodb中binary log entries总是以事务为单位整体写入文件的。


Within an uncommitted transaction, all updates (UPDATE, DELETE, or INSERT) that change transactional tables such as BDB or InnoDB tables are cached until a COMMIT statement is received by the server. At that point, mysqld writes the entire transaction to the binary log before the COMMIT is executed.


1. 只有事务完成了,相关记录才会进入binlog文件

2. 一个写事务不应该太长,否则当它被整体写入binlog文件时,会长时间占用binlog,导致其他事务在这段时间内无法写入binlog,因而无法提交,最终影响并发性能。

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.