Bug #95165 Be more robust if mysql_upgrade_info is not writable
Submitted: 27 Apr 2019 5:09 Modified: 29 May 2019 17:21
Reporter: Terje Røsten Email Updates:
Status: Closed Impact on me:
Category:MySQL Server: Data Dictionary Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: CPU Architecture:Any

[27 Apr 2019 5:09] Terje Røsten
If mysql_upgrade_info in $datadir is not writable by mysql user, upgrade fails and server stops, this is a bit too drastic. 

Be more robust and just give a warning and let server continue start up.

See e.g: https://forums.mysql.com/read.php?11,674428,674428 for such problem.

How to repeat:
Create mysql_upgrade_info in $datadir and make is not writable by user running mysql server, do upgrade from 8.0.15 to 8.0.16.

Suggested fix:
Turn fatal error into warning.
[27 Apr 2019 22:38] Piotr Jurkiewicz
The `mysql_upgrade_info` file before 8.0.16 was being created by `mysql_upgrade` command, which was being run manually by user. The OS user, who was ran this command last time, is the owner of the file. And he is the only one being able to modify this file now.

Usually, this is not `mysql` user, but either `root` or personal user account of DBA. 

So this bug will prevent upgrade to 8.0.16 in vast majority of cases. Actually, upgrade to 8.0.16 will happen flawlessly only for those who never ran `mysql_upgrade` command.

I think it should fixed ASAP, for example by adding command `chown mysql:mysql $datadir/mysql_upgrade_info` to 8.0.16 packages installation/upgrade scripts.
[27 Apr 2019 22:43] Piotr Jurkiewicz
See: https://gist.github.com/rjha/9012d6a077e79f9d3aa31497044fd765

This happens not only on Debian/Ubuntu, but also on Centos etc.
[8 May 2019 13:38] Terje Røsten

New DEB and RPMS packages (8.0.16-2) have been added to repos.

These packages should reduce the risk of errors due to non-writable mysql_upgrade_info file in datadir.
[13 May 2019 19:14] Niraj Thapa
Any estimation on when the fix for TAR for Generic Linux 64 bit be released.

I am having the same issue, but I use TAR for Generic Linux 64 bit for my MySQL installations.
[15 May 2019 15:49] James Toothman
I can confirm that this bug also occurs on FreebSD (11.2).

Upgrading today mysql80-server: 8.0.15_2 -> 8.0.16 using the FreeBSD pkg system, mysql-server could not complete the upgrade and could not be started.  I had used the mysql_upgrade command after each prior mysql server upgrade, leaving a file owned by root.

Running 'chown mysql /var/db/mysql/mysql_upgrade_info' resolved this issue for me.
[22 May 2019 16:20] Niraj Thapa
The problem with my situation is that I do not have 'mysql' OS user to make it the owner of '/var/db/mysql/mysql_upgrade_info' file. I have a non standard custom user that is currently the owner of all MySQL files and software. 
I am looking forward for MySQL to release the fix for:
"MySQL Commercial Server 8.0.16 TAR for Generic Linux x86 (64bit)"
[29 May 2019 17:21] Daniel Price
Posted by developer:
Fixed as of the upcoming 8.0.17 release, and here's the changelog entry:

A mysql_upgrade_info file created by the mysql_upgrade program during a
previous upgrade could only be modified the operating system user that
executed the mysql_upgrade program, causing an upgrade error. A warning is
now issued instead of an error, which permits the upgrade operation to
proceed. The mysql_upgrade_info file is deprecated and will be removed in
a future MySQL version. 

The deprecation is also noted in the reference manual, in the What's New, upgrade, and mysql_upgrade sections.