Innodb mysql database corruption lead to deadlock

Problem
MySQL since version 3.23.58, provides engine called InnoDB provides features such as stored procedures
when the server power outages and other unexpected error occurred, could lead to deadlock innodb
view with top command, found mysqld process takes up to 100% cpu and not start properly, shut down

070316 12:30:43 mysqld started
070316 12:30:43 InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
070316 12:30:43 InnoDB: Starting log scan based on checkpoint at
InnoDB: log sequence number 0 2347685.
InnoDB: Doing recovery: scanned up to log sequence number 0 2347685
070316 12:30:43 InnoDB: Error: page 4 log sequence number 0 1516429185
InnoDB: is in the future! Current system log sequence number 0 2347685.
InnoDB: Your database may be corrupt.

Solution
First to completely kill all mysql process running, and temporarily stop the web server, so as not to start again mysql call
/etc/init.d/httpd STOP
killall -9 mysqld
killall -9 mysqld_safe

Now with ps awxuf mysql command confirmed that no related processes in the run
to the next / var / lib / mysql directory, find ibdata1, ib_logfile0, ib_logfile1 and several other files, renaming or moving away
execution /etc/init.d/mysqld restart restart mysqld

这时候再查看log,就会发现innodb的引擎会重建出错的文件
070316 12:41:35 mysqld started
InnoDB: The first specified data file ./ibdata1 did not exist:
InnoDB: a new database to be created!
070316 12:41:35 InnoDB: Setting file ./ibdata1 size to 10 MB
InnoDB: Database physically writes the file full: wait...
070316 12:41:35 InnoDB: Log file ./ib_logfile0 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile0 size to 5 MB
InnoDB: Database physically writes the file full: wait...
070316 12:41:35 InnoDB: Log file ./ib_logfile1 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile1 size to 5 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
070316 12:41:36 InnoDB: Started; log sequence number 0 0
/usr/libexec/mysqld: ready for connections.
Version: '4.1.12' socket: '/var/lib/mysql/mysql.sock' port: 3306 Source distribution

We can now confirm that mysqld running through the top order.

/Etc/init.d/httpd start to perform normal start web services, and observe whether mysql normal, the general failure can be resolved

Note: If you want to disable innodb function, you can /etc/my.cnf inside the [mysqld] section, add the following line:
Skip-innodb
then restart the mysqld service, you can disable innodb.
But not recommended to disable, if part of a program called mysql stored procedures, then it can not work.

Guess you like

Origin www.cnblogs.com/sfqas/p/12181825.html