Bug #13494 Log size differences create possibility of corruption
Submitted: 26 Sep 2005 20:35 Modified: 30 Sep 2008 22:31
Reporter: C.J. Adams-Collier
Status: Open
Category:Server: InnoDB Severity:S4 (Feature request)
Version:4.0.24_Debian-10-log OS:Linux (Debian GNU)
Assigned to: Heikki Tuuri Target Version:
Triage: D5 (Feature request)

[26 Sep 2005 20:35] C.J. Adams-Collier
Description:
/etc/mysql/my.cnf contains a an innodb log size different than on-disk log file size:
set-variable = innodb_log_file_size=20M

$ ls -ld /var/lib/mysql/ib_logfile0
-rw-rw----  1 mysql mysql 5242880 2005-09-18 05:10 /var/lib/mysql/ib_logfile0

$ sudo mysqld
InnoDB: Error: log file ./ib_logfile0 is of different size 0 5242880 bytes
InnoDB: than specified in the .cnf file 0 20971520 bytes!
050926 10:58:25 Can't init databases
050926 10:58:25 Aborting

050926 10:58:25  InnoDB: Warning: shutting down a not properly started
                 InnoDB: or created database!
050926 10:58:25 mysqld: Shutdown Complete

Syslog contents:

---

Sep 26 11:07:55 norseth mysqld[15355]: InnoDB: Error: log file ./ib_logfile0 is of
different size 0 5242880 bytes
Sep 26 11:07:55 norseth mysqld[15355]: InnoDB: than specified in the .cnf file 0 20971520
bytes!
Sep 26 11:07:55 norseth mysqld[15355]: 050926 11:07:55 Can't init databases
Sep 26 11:07:55 norseth mysqld[15355]: 050926 11:07:55 Aborting
Sep 26 11:07:55 norseth mysqld[15355]: 
Sep 26 11:07:55 norseth mysqld[15355]: 050926 11:07:55  InnoDB: Warning: shutting down a
not properly started
Sep 26 11:07:55 norseth mysqld[15355]:                  InnoDB: or created database!
Sep 26 11:07:55 norseth mysqld[15355]: 050926 11:07:55 /usr/sbin/mysqld: Shutdown
Complete

---

The solution is to stop MySQL, change the line in my.cnf:
set-variable = innodb_log_file_size=5M

and re-start the daemon.

After the daemon re-starts, stop it, move the log file out of the way, change the size in
the my.cnf file, and re-start the daemon.

This will re-set the size of the log file to whatever is in the config file.

There is a lot of room for slip-up here.

How to repeat:
See above

Suggested fix:
There should be some sort of wrapper around the process.  JamesDay tells me that this is
one of the largest problems causing innodb corruption.  If the log file is damaged, the
database has a great potential to become corrupted.
[26 Sep 2005 21:50] Heikki Tuuri
Hi!

In your example case, no corruption can occur. InnoDB simply refuses to start with a log
file of a wrong size.

Further corruption CAN occur if mysqld crashes and the user tries to resolve the problem
by deleting old ib_logfiles, or replacing them with wrong ib_logfiles. But then the
database is probably corrupt anyway, because otherwise the user would have been happy
with the automatic crash recovery of InnoDB.

The main problem that I have observed is diagnosing the crashes that result from wrong
logfiles. It is often difficult to tell why mysqld segfaulted.

The following feature would solve this diagnosis problem:

http://www.innodb.com/todo.php
"
Add more safety checks that would prevent one from using wrong ib_logfiles with ibdata
files. InnoDB could once per minute stamp the current lsn to the trx system page in
ibdata1, and at a startup compare the stamp to the log files, as well as to the shutdown
lsn stamps in the ibdata files.
"

Regards,

Heikki
[30 Sep 2008 22:31] C.J. Adams-Collier
Thanks Heikki,

Has this feature been implemented since last we spoke?

Cheers,

C.J.