Redo Log Format

InnoDB redo logs record all modifications to tablespace pages, enabling crash recovery. The logs are organized as a sequence of 512-byte blocks.

File Layout

BlockPurpose
0File header
1Checkpoint 1
2Reserved
3Checkpoint 2
4+Data blocks containing log records

File Header (Block 0)

OffsetSizeFieldDescription
04Group IDRedo log group identifier
48Start LSNLSN of the first log record in this file
124File numberSequence number within the redo log group
1632Creator stringServer version and vendor (e.g., "MySQL 8.0.32", "Percona XtraDB 8.0.35")

The creator string is particularly useful for vendor detection -- it identifies whether the redo log was created by MySQL, Percona XtraDB, or MariaDB.

Checkpoint Blocks (Blocks 1 and 3)

Two checkpoint blocks provide redundancy. InnoDB alternates between them, so at least one is always valid after a crash.

OffsetSizeFieldDescription
08Checkpoint numberMonotonically increasing checkpoint counter
88LSNLSN up to which all changes are flushed to tablespace files
164Byte offsetOffset within the log file for this checkpoint
204Log buffer sizeSize of the log buffer in bytes
248Archived LSNLSN up to which logs have been archived (0 if archiving disabled)

The checkpoint with the higher checkpoint number is the most recent. During crash recovery, InnoDB replays all log records from the checkpoint LSN forward.

Data Block Header (14 bytes)

Each data block (block 4 and beyond) starts with a 14-byte header:

OffsetSizeFieldDescription
04Block numberSequential block number; bit 31 is the flush flag (1 = first block in a flush batch)
42Data lengthNumber of bytes of log data in this block (max 494)
62First record group offsetOffset to the first complete log record group starting in this block
84Checkpoint numberCheckpoint number when this block was written
122PaddingReserved bytes

Data Block Checksum

Each block ends with a 4-byte CRC-32C checksum:

  • Computed over bytes [0..508) of the block
  • Stored at bytes [508..512)

inno log validates block checksums and reports any corruption.

Block Capacity

Each 512-byte block carries at most 494 bytes of log record data:

[header: 14 bytes][log data: up to 494 bytes][checksum: 4 bytes]
 0             13  14                    507  508           511

Log records can span multiple blocks. The data length field indicates how many bytes of the 494-byte payload contain actual log data (the rest is padding).

File Formats

Legacy Format (MySQL < 8.0.30)

  • Files: ib_logfile0, ib_logfile1 (or more, controlled by innodb_log_files_in_group)
  • Fixed-size files, pre-allocated at server startup
  • Location: MySQL data directory root

New Format (MySQL 8.0.30+)

  • Files: #innodb_redo/#ib_redo* (numbered sequentially)
  • Dynamic file creation and removal
  • Location: #innodb_redo/ subdirectory within the data directory
  • inno log supports both formats

MLOG Record Types

Redo log records use type codes to identify the operation. Common types include:

TypeValueDescription
MLOG_1BYTE1Write 1 byte to a page
MLOG_2BYTES2Write 2 bytes to a page
MLOG_4BYTES4Write 4 bytes to a page
MLOG_8BYTES8Write 8 bytes to a page
MLOG_REC_INSERT9Insert a record (non-compact format)
MLOG_REC_UPDATE_IN_PLACE13Update a record in place
MLOG_REC_DELETE14Delete a record
MLOG_PAGE_CREATE16Create a page
MLOG_UNDO_INSERT20Insert an undo log record
MLOG_INIT_FILE_PAGE24Initialize a file page
MLOG_COMP_REC_INSERT38Insert a record (compact format)
MLOG_COMP_REC_UPDATE_IN_PLACE42Update a record in place (compact format)
MLOG_COMP_REC_DELETE43Delete a record (compact format)
MLOG_COMP_PAGE_CREATE44Create a page (compact format)

The MLOG_COMP_* variants are used by the compact row format (MySQL 5.0+), while the non-compact versions correspond to the older redundant row format.

Usage with inno

# Parse a legacy redo log
inno log -f /var/lib/mysql/ib_logfile0

# Parse a new-format redo log
inno log -f /var/lib/mysql/#innodb_redo/#ib_redo10

# Show specific blocks
inno log -f ib_logfile0 -b 0-10

# Skip empty blocks
inno log -f ib_logfile0 --no-empty

# Verbose output with block checksums
inno log -f ib_logfile0 -v

# JSON output
inno log -f ib_logfile0 --json