InnoDB Tablespaces, Redo Logs and Crash Recovery
InnoDB keeps table data in tablespaces and uses its redo log to bring data pages forward after a crash. Undo records roll back transactions that never finished, and the binary log is a separate, server-level history used for point-in-time recovery and replication. Recovery starts by choosing which of these paths the situation needs, and by preserving the files before any engine start can change them.
- Redo brings pages forward after a crash, undo rolls back unfinished transactions, and the binary log serves point-in-time recovery.
- Whether a recently acknowledged commit survives depends on flush and commit settings and on storage honouring flushes.
- Starting the server, crash recovery and backup preparation can all write; preserve the original files before any of them runs.
innodb_force_recoveryis for extracting data from a working copy; it does not repair or validate anything.- Accept a result by required tables, rows, constraints and business checks, not because the server started or a dump finished.
Redo, undo and the binary log are different records
The MySQL 8.4 manual describes the redo log as a disk-based structure used during crash recovery to correct data written by incomplete transactions. Its crash-recovery sequence discovers the tablespaces that need redo, applies redo before accepting connections, rolls back transactions that were active at the crash, merges buffered secondary-index changes and purges delete-marked records. Redo therefore restores the physical state of pages up to the last logged change, including changes that the following rollback step then undoes. It is not a list of committed transactions.
Undo records are what rollback and consistent reads use. The binary log is a different mechanism at the server level: changes recorded there are applied after a restored backup to reach a chosen point in time, and they exist only if binary logging was enabled before that backup. An uncleanly stopped instance with matching data and redo files can be fully crash-recoverable without being corrupt.
The manual is explicit about one shortcut: removing redo logs to speed up recovery is not recommended even when some data loss is acceptable, and is only considered after a clean shutdown. Unflushed changes can exist only in redo.
Durability depends on settings and the storage stack
InnoDB follows a write-ahead model, but the guarantee a given instance actually provides is configuration-dependent. MySQL’s description of the durability part of ACID lists the redo flush setting at commit, the binary-log sync setting, the doublewrite buffer, write caches in the storage device, battery-backed caches, the operating system’s fsync() support and power protection. With settings that flush at each commit and storage that honours those flushes, a committed transaction survives a crash; with other settings, or with a cache that acknowledges writes it has not persisted, a recently acknowledged commit may be missing.
Record the settings that were in effect at the incident. Changing them during an incident recovers nothing and changes what later evidence means.
What to inventory before anything starts
- The exact server version and distribution. This page follows the MySQL 8.4 manual; MariaDB and other forks differ in file layout and recovery options.
- The configuration file and the settings that shape the files: page size, data and log directories, file-per-table, undo and redo settings.
- The system tablespace, general and file-per-table tablespaces, undo tablespaces and the data dictionary.
- Redo log files. In 8.4 they live in an
#innodb_redodirectory as#ib_redoNfiles; other versions use different names and locations, so inventory by version rather than by an expected filename. - Doublewrite files where they are configured, the error log, existing backups, the binary logs from the backup position onward, and keyring or encryption material if tablespace encryption is in use.
A single .ibd file copied on its own lacks the dictionary and, if encrypted, the key context. It is not necessarily a table that another instance can attach.
Starting the engine is not a passive read
Starting the engine can apply redo, roll back transactions and run change-buffer merge or purge, all of which can change database files. Tablespace discovery is not, by itself, the same operation as applying those changes. A hot-backup tool typically needs its own prepare step that applies logs to the backup copy. Preserve the original bytes and state before the engine or a prepare step touches them: a copy of the stopped data directory, a storage snapshot whose scope covers every data and log volume together, or an image of the device, chosen by the situation. A downtime window or a full device image is not the only acceptable form of preservation.
A file-by-file copy of a running data directory can produce a set of files that never existed together, even if every file copied without an error. Hot backups have their own consistency and prepare requirements, and a completed copy or live snapshot does not prove an atomic state. See Live Systems, Snapshots and Consistent Recovery Copies and Recovery Copies: Source, Image, Working Copy and Destination.
Crash recovery, restore with point-in-time recovery, or extraction
Scroll horizontally to see the full table →
| Path | When it fits | What it needs | What it changes |
|---|---|---|---|
| Crash recovery | Unclean shutdown; data and log files belong together | Matching tablespaces, redo and undo from the same instance | Writes data files as redo is applied and transactions roll back |
| Restore and point-in-time recovery | Corruption, disk failure, or a change that has to be undone | A usable base backup and continuous binary logs from its position, plus any encryption material | Builds a new instance; the damaged one stays as evidence |
| Emergency extraction | No usable backup and the instance will not start normally | A working copy of the preserved files | Writes the working copy; output may be incomplete or inconsistent |
For corruption or disk failure, the manual directs recovery through a backup. Point-in-time recovery needs a base backup that restores, binary logs that continue without a gap from its position (or the corresponding GTID context), and the keys the backup and logs depend on. Logs are not replayed from an arbitrary time or from another instance. Document the accepted point and any known gap.
Forced recovery is for extraction from a copy
MySQL documents innodb_force_recovery as a way to start InnoDB in an emergency so that tables can be dumped, after making a backup copy of the database. Any nonzero value blocks INSERT, UPDATE and DELETE; values of 4 or more put InnoDB in read-only mode, and the manual warns that those values can permanently corrupt data files and should be tested on a separate physical copy first.
Blocking DML does not mean the files are untouched, and the levels change what the extracted data represents: one level skips rollback after recovery, another treats incomplete transactions as committed, another skips redo roll-forward. Rows extracted this way can include changes that never committed or miss changes that did. The setting is not a fix, and an instance that starts with it is not validated. This page gives no level sequence or retry routine; the choice belongs on a working copy, with each attempt recorded.
Secondary indexes and doublewrite: what they can and cannot do
A secondary index is derived from the clustered index, so it can be rebuilt when the clustered data and the dependencies it needs are confirmed intact. That makes damage confined to a secondary index easier to recover from in that case; it does not make secondary-index corruption a category that is always less serious. A rebuild writes, and it shows nothing about how much of the base data is recoverable.
The doublewrite buffer protects against torn page writes: pages are written to doublewrite files first, so that crash recovery can find a good copy if a page write to its final location is interrupted. It is not a backup of all pages and does not protect against arbitrary overwrites. Its mode matters: with the detect-only setting, only metadata is written to the buffer and recovery does not use it to fix incomplete writes, and it can be switched off. A page that passes its checksum can still be an older version that lacks committed rows.
Accepting the result
A server that starts and a dump that completes are intermediate results. Accept the outcome by:
- the tables the owner needs being present, with plausible row counts and working primary and foreign keys;
- constraints and application-level checks passing;
- business totals reconciling with independent records where they exist;
- the recovery point and known gaps written down, including whether extraction used a forced-recovery mode.
The same separation of backup restore, extraction and repair applies to SQL Server; see SQL Server Corruption, Page Restore and DBCC and How to Validate Recovered Data.
Removing redo log files can discard changes that exist nowhere else. Preserve the data directory, redo and undo files and the configuration before any restart, recovery mode or backup preparation.
Technical references: MySQL 8.4, §17.18.2 InnoDB Recovery — crash-recovery steps, redo removal, point-in-time recovery · MySQL 8.4, §17.20.3 Forcing InnoDB Recovery — purpose, levels, read-only and corruption warnings · MySQL 8.4, §17.6.4 Doublewrite Buffer — torn writes, detect-only mode · MySQL 8.4, §17.2 InnoDB and the ACID Model — what durability depends on. Redo file location is from §17.6.5 Redo Log. Pages checked October 2026 for MySQL 8.4; file layout, defaults and options differ in other versions and in MariaDB.
Related: Database Page Corruption and Transaction Recovery · SQL Server Corruption, Page Restore and DBCC · Database Corruption (SQL Server, MySQL, and Similar) · Live Systems, Snapshots and Consistent Recovery Copies · VM, Database and Application-Container Recovery Tools