Backing Up and Recovering an
InnoDB
Database
1262
InnoDB: Rollback of uncommitted transactions completed
InnoDB: Starting an apply batch of log records to the database...
InnoDB: Apply batch completed
InnoDB: Started
mysqld: ready for connections
If your database becomes corrupted or disk failure occurs, you must perform the recovery using a
backup. In the case of corruption, you should first find a backup that is not corrupted. After restoring the
base backup, do a point-in-time recovery from the binary log files using
mysqlbinlog
and
mysql
to
restore the changes that occurred after the backup was made.
In some cases of database corruption it is enough just to dump, drop, and re-create one or a few
corrupt tables. You can use the
CHECK TABLE
SQL statement to check whether a table is corrupt,
although
CHECK TABLE
naturally cannot detect every possible kind of corruption. You can use the
Tablespace Monitor to check the integrity of the file space management inside the tablespace files.
In some cases, apparent database page corruption is actually due to the operating system corrupting
its own file cache, and the data on disk may be okay. It is best first to try restarting your computer.
Doing so may eliminate errors that appeared to be database page corruption.
14.2.5.1. The
InnoDB
Recovery Process
InnoDB
crash recovery consists of several steps. The first step, redo log application, is performed
during the initialization, before accepting any connections. If all changes were flushed from the buffer
pool to the tablespaces (
ibdata*
and
*.ibd
files) at the time of the shutdown or crash, the redo
log application can be skipped. If the redo log files are missing at startup,
InnoDB
skips the redo log
application.
The remaining steps after redo log application do not depend on the redo log (other than for logging the
writes) and are performed in parallel with normal processing. These include:
• Rolling back incomplete transactions: Any transactions that were active at the time of crash or fast
shutdown.
• Insert buffer merge: Applying changes from the insert buffer tree (from the shared tablespace) to leaf
pages of secondary indexes as the index pages are read to the buffer pool.
• Purge: Deleting delete-marked records that are no longer visible for any active transaction.
Of these, only rollback of incomplete transactions is special to crash recovery. The insert buffer merge
and the purge are performed during normal processing.
14.2.5.2. Forcing
InnoDB
Recovery
If there is database page corruption, you may want to dump your tables from the database with
SELECT ... INTO OUTFILE
. Usually, most of the data obtained in this way is intact. However,
it is possible that the corruption might cause
SELECT * FROM tbl_name
statements or
InnoDB
background operations to crash or assert, or even cause
InnoDB
roll-forward recovery to crash. In
such cases, you can use the
innodb_force_recovery
[1243]
option to force the
InnoDB
storage
engine to start up while preventing background operations from running, so that you are able to dump
your tables. For example, you can add the following line to the
[mysqld]
section of your option file
before restarting the server:
[mysqld]
innodb_force_recovery = 4
innodb_force_recovery
[1243]
is 0 by default (normal startup without forced recovery) The
permissible nonzero values for
innodb_force_recovery
[1243]
follow. A larger number includes
all precautions of smaller numbers. If you are able to dump your tables with an option value of at most
4, then you are relatively safe that only some data on corrupt individual pages is lost. A value of 6 is
more drastic because database pages are left in an obsolete state, which in turn may introduce more
corruption into B-trees and other database structures.
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...