postinst runs mysql_upgrade before server is properly started ( Can't connect [...] '/var/run/mysqld/mysqld.sock)
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
mysql-5.7 (Ubuntu) |
Triaged
|
High
|
Lars Tangvald | ||
Xenial |
Triaged
|
High
|
Unassigned |
Bug Description
Hello,
The corresponding apt error message looks like this:
...
Do you want to continue? [Y/n]
Setting up mysql-server-5.7 (5.7.17-
Renaming removed key_buffer and myisam-recover options (if present)
mysql_upgrade: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/
Upgrade process encountered error and will not continue.
mysql_upgrade failed with exit status 11
dpkg: error processing package mysql-server-5.7 (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-5.7; however:
Package mysql-server-5.7 is not configured yet.
dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
mysql-server-5.7
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
The workaround is to put a `sleep 3` on the 320. line of mysql-server-
The root cause seems to be that invoke-rc.d does not execute systemctl --wait, and systemctl without wait doesn't wait until the database server daemon is up and listening.
And of course it could be mitigated by using a systemd socket for mysql.
Changed in mysql-5.7 (Ubuntu Xenial): | |
status: | New → Triaged |
importance: | Undecided → High |
Changed in mysql-5.7 (Ubuntu): | |
assignee: | nobody → Lars Tangvald (lars-tangvald) |
Thank you for taking the time to report this bug and helping to make Ubuntu better.
I think we have seen some other reports of mysql_upgrade failures like this but so far had been unable to reproduce and did not have a technical explanation. Thank you very much for providing this. We can probably duplicate other reports to this bug.
Separately, we're overhauling how mysql_upgrade is called due to bug 1592669. Our planned solution for that bug is to no longer use invoke-rc.d to start mysqld before running mysql_upgrade at all. Instead we'll run a "private" daemon that runs with networking and ACLs disabled in a root-only private socket so that mysql_upgrade can then run unhindered, and then shut it down again. So when that bug is resolved, I think this (looks valid) bug will become moot.
I subscribed Lars for his attention.
Thank you again for the report.