Thu, 03 Apr 2008

InnoDB being silently disabled

Regular viewers will know that I don't think favourably of MySQL. Here is yet another reason. Let's create an InnoDB table:

mysql> CREATE TABLE `User_` (
mysql> ...
mysql> ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Query OK, 0 rows affected, 1 warning (0.04 sec) 

One warning, but we're running this as part of an import, so we'll fail to spot this and even if we did, we wouldn't be able to get it back out of mysql because SHOW WARNINGS only shows the last command. So let's look at the table we just created:

mysql> show create table User_\G
*************************** 1. row ***************************
       Table: User_
Create Table: CREATE TABLE `User_` (
...
) ENGINE=MyISAM DEFAULT CHARSET=latin1
1 row in set (0.00 sec)

Eh? what's going on? We asked for InnoDB, but have got a MyISAM table. Lets look at the engines available.

mysql> show engines;
+------------+----------+----------------------------------------------------------------+
| Engine     | Support  | Comment                                                        |
+------------+----------+----------------------------------------------------------------+
| MyISAM     | DEFAULT  | Default engine as of MySQL 3.23 with great performance         | 
| MEMORY     | YES      | Hash based, stored in memory, useful for temporary tables      | 
| InnoDB     | DISABLED | Supports transactions, row-level locking, and foreign keys     | 
| BerkeleyDB | NO       | Supports transactions and page-level locking                   | 
| BLACKHOLE  | NO       | /dev/null storage engine (anything you write to it disappears) | 
| EXAMPLE    | NO       | Example storage engine                                         | 
| ARCHIVE    | YES      | Archive storage engine                                         | 
| CSV        | YES      | CSV storage engine                                             | 
| ndbcluster | DISABLED | Clustered, fault-tolerant, memory-based tables                 | 
| FEDERATED  | YES      | Federated MySQL storage engine                                 | 
| MRG_MYISAM | YES      | Collection of identical MyISAM tables                          | 
| ISAM       | NO       | Obsolete storage engine                                        | 
+------------+----------+----------------------------------------------------------------+
12 rows in set (0.00 sec)

Oh, so innodb has been disabled. We can fix that easily by removing skip-innodb from my.cnf.

root@cmsdb01:/var/log# grep skip-innodb /etc/mysql/my.cnf
root@cmsdb01:/var/log#

But hang on a second, that's not in the config file. What's going on? It turns out that the reason InnoDB is disabled is because of the innodb_log_file_size setting not matching the files on disk.

root@cmsdb01:/var/log# grep innodb_log_file_size /etc/mysql/my.cnf
innodb_log_file_size            = 512M
root@cmsdb01:/var/log# ls -lh /var/lib/mysql/ib_logfile*
-rw-rw---- 1 mysql mysql 5.0M 2006-12-19 18:39 /var/lib/mysql/ib_logfile0
-rw-rw---- 1 mysql mysql 5.0M 2006-12-19 18:39 /var/lib/mysql/ib_logfile1

Rumour has it that you can just stop MySQL, delete these log files and start MySQL again. I'm yet to try this as the server in question is in production use. The alternative is to change the innodb_log_file_size setting to match the file.

So in summary the problems with MySQL are:

  • Not logging warnings anywhere useful.
  • Converting engine types with a warning rather than throwing an error. This can be fixed by setting sql_mode to include NO_ENGINE_SUBSTITUTION.
  • Starting up and disabling InnoDB when there is a problem rather than failing to start, giving a false impression that everything is working.
MySQL has not impressed me this week.

[database,MySQL,gotchas,InnoDB] | # Read Comments (8) |

Comments

I've been using MySQL in my own projects for a while now, and after reading your post (and others like it), I feel very lucky not to have been bitten by these nasty bugs.  It's almost like when I was first beginning to realize that Microsoft products weren't so good after all.  Maybe I should switch to PostgreSQL?
Posted by Alex at Thu Apr 3 14:58:30 2008
If you want a good laugh about mysql, have a read of this:

http://archives.postgresql.org/pgsql-docs/2003-08/msg00013.php

In other news, I've just redefined
"1+7+3+5+2" to be "8" since that, too, would save me having to "evaluate a lot of extra expressions in
this case."
Posted by Jaime at Thu Apr 3 16:08:31 2008
You know, 2-3 years ago I did a review of the applications and the data we store in MySQL, they aren't that big ~10GB. My conclusion was that, no we didn't have any data inconsistencies, and yes MySQL was hell of a lot faster than Postgres.

Just saying the right thing isn't always best.
Posted by Erik J at Fri Apr 4 08:26:58 2008
It was really helpful for me.
Thanks ;)
Posted by Mehdi at Thu Apr 24 11:47:09 2008
Thank you for this post - it helped me work through this problem, which I had when setting up a new machine.  By the way, the rumor about stopping mysql, removing the ib_logfile[0|1] files, and restarting mysql worked for me.
Posted by Will R at Fri May 9 19:06:46 2008
Thanks for this article, we just ran into this issue during the migration of a production system. "Just" means two weeks ago, we noticed it today and we're still trying to locate any problems that might have been caused by transactions that were not rolled back.
What additionally adds to this problem is that show variables and status still show the InnoDB related rows, and if there are no obvious problems you won't take a closer look that would make you think about why in show status almost all values are 0.
Posted by Tammo at Wed Aug 20 16:14:14 2008
Same problem here:
http://forums.mysql.com/read.php?22,74573,74573#msg-74573

Where the suggestion is to remove log files and restart.
Posted by Matt B at Wed Jan 14 23:46:16 2009
Please add the MySQL version where this occurred, maybe the linux distro if it was supplied from one, thanks.
Posted by Chris at Thu Aug 11 15:30:42 2011

Name:


E-mail:


URL:


Comment:


Please enter "fudge" to prove you are a human