Bug #77516 Crash loop with 5.6.25 after importing 5.0 database if mysql_upgrade omitted
Submitted: 27 Jun 2015 17:23 Modified: 15 Jul 2015 7:07
Reporter: Phil Stracchino Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Security: Privileges Severity:S3 (Non-critical)
Version:5.6.25 OS:Any
Assigned to: CPU Architecture:Any

[27 Jun 2015 17:23] Phil Stracchino
Description:
We just performed an upgrade of a customer DB server from MySQL Community 5.0.95 to 5.6.25.  As recommended,, we performed the upgrade via a full dump and reload.  Unfortunately, after 12 hours of copying data and rearranging filesystems, we forgot to run the mysql_upgrade script before restarting MySQL.

Under these circumstances the format of the system tables is of course wrong.  We would fully expect that MySQL would emit an error message stating that the grant tables were incorrect and had been skipped, or even abort saying that it could not read the system tables and advise that we restart using skip-grant-tables and fix the problem.

What actually happened was that mysqld went into a tight infinite crash loop, dying about a half second after startup with a SIGSEGV, immediately being restarted by mysqld_safe, immediately dying again after a half second, and so on.  There was no indication of what the real problem was.  We wiped and reloaded the data twice in case we'd gotten a bad load somehow, unmounted and fsck'd the filesystem, all to no avail.

Once we realized what the problem was, we were able to fix it without further problems by starting MySQL with skip-grant-tables and then running mysql_upgrade.

I do not expect MySQL 5.6 to be able to start and run properly with MySQL 5.0 grant tables, and it was only due to oversight on our part that we attempted to do so.  However, MySQL's behavior in the face of this error — an endless crash loop with no obvious reason — was clearly much less than ideal.

How to repeat:
We do not know how repeatable this is.  We accomplished it by loading a complete dump of a 5.0.95 DB, including system tables, into a brand new 5.6.25 instance and then doing a test restart, inadvertently before running mysql_upgrade.

Suggested fix:
I do not have a "fix" per se, but I would suggest that in this situation, the correct behavior would be for MySQL to abort with an error message that there is a problem with the system tables, and advise the user to restart using skip-grant-tables and fix the problem.  The silent crash-loop behavior is clearly wrong, especially as it offers absolutely no clues as to what is the actual underlying problem.  Absolutely, mysqld should *abort* if its system tables are invalid; but it should not *crash*, and mysqld_safe should abort with it, not create an infinite loop.
[15 Jul 2015 7:07] MySQL Verification Team
Hello Phil,

Thank you for the report.
This is most likely duplicate of Bug #70431.
My colleague Shane Bester has internally filed enhancement request to handles this kind of scenarios like 5.6 needs to be able to start up with 5.0, 5.1, 5.5 or 5.6 system tables etc , and provide a reasonable error message if they are outdated, and ability to run mysql_upgrade instead of it crashes in a loop.

Thanks,
Umesh