MySQL Service Crashes After Drive Failure

If a hard drive fails while MySQL is trying to write to the disk, the database could get corrupted. If that happens then you might see the MySQL service crashing every time when the first request is made after it starts. The error log might display something like this:

InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer…
InnoDB: Doing recovery: scanned up to log sequence number 0 373839829
InnoDB: Assertion failure in thread 4868 in file .\trx\trx0purge.c line 476
InnoDB: Failing assertion: trx_sys->rseg_history_len >= n_removed_logs
InnoDB: We intentionally generate a memory trap.
mysqld got exception 0xc0000005 ;
InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer…InnoDB: Doing recovery: scanned up to log sequence number 0373839829
InnoDB: Assertion failure in thread 4868 in file .\trx\trx0purge.c line 476
InnoDB: Failing assertion: trx_sys->rseg_history_len >= n_removed_logs
InnoDB: We intentionally generate a memory trap.
mysqld got exception 0xc0000005 ;

You can try backing up and recreating the databases to fix it. Edit my.ini and set innodb_force_recovery = 4 in the [mysqld] section to prevent MySQL from crashing. Then do a mysqldump*, drop the databases and then import them from the backup.

If that doesn’t work, the docs have some other tips.

* The dump won’t include any corrupted data, so it might also be a good idea to backup the entire data directory in case you need to try to recover the corrupted data later on.

Leave a Reply

Your email address will not be published. Required fields are marked *