mysql(一):基本原理

发布时间 2023-06-02 22:25:04作者: Bota5ky

Innodb是如何实现事务的

Innodb通过Buffer Pool,LogBuffer,Redo Log,Undo Log来实现事务,以一个update语句为例:

  1. Innodb在收到一个update语句后,会先根据条件找到数据所在的页,并将该页缓存在Buffer Pool中
  2. 执行update语句,修改Buffer Pool中的数据,也就是内存中的数据
  3. 针对update语句生成一个RedoLog对象,并存入LogBuffer中
  4. 针对update语句生成undolog日志,用于事务回滚
  5. 如果事务提交,那么则把Redolog对象进行持久化,后续还有其他机制将Buffer Pool中所修改的数据页持久化到磁盘中
  6. 如果事务回滚,则利用undolog日志进行回滚

零时刻导致flyway执行失败

When run the flyway failed in the history scripts because of the scripts with timestamp having no default value.

Check the local mysql environment —— the sql_mode, delete the NO_ZERO_DATE and NO_ZERO_IN_DATE.

SELECT @@GLOBAL.sql_mode;
SET GLOBAL sql_mode = "XXX";

XXX is the result of select SQL and remove the NO_ZERO_DATE and NO_ZERO_IN_DATE. For example:

SET GLOBAL sql_mode = "ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION";