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.
8 comments
Comments are closed. These are preserved from the original site.
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?
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."
Just saying the right thing isn't always best.
Thanks ;)
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.
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.
http://forums.mysql.com/read.php?22,74573,74573#msg-74573
Where the suggestion is to remove log files and restart.
Please add the MySQL version where this occurred, maybe the linux distro if it was supplied from one, thanks.