The unsung heroes of InnoDB are the logfiles. They are what makes
InnoDB automatic crash recovery possible.
Database administrators of other DBMS may be familiar with the
concept of a “redo” log. When data is changed, affected data
pages are changed in the innodb_buffer_pool. Then, the change is
written to the redo log, which in MySQL is the InnoDB logfile
(ib_logfile0 and ib_logfile1). The pages are marked as “dirty”,
and eventually get flushed and written to disk.
If MySQL crashes, there may be data that is changed that has not
been written to disk. Those data pages were marked as “dirty” in
the innodb_buffer_pool, but after a MySQL crash the
innodb_buffer_pool no longer exists. However, they were written
to the redo log. On crash recovery, MySQL can read the redo log
(InnoDB log files) and apply any changes that were not written to
disk.
That is the basic functionality of the InnoDB log files. Given
this, …
[Read more]