postinst fails when daemon is not running (or is disabled by policy-rc.d)
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
mysql-5.7 (Debian) |
Fix Released
|
Unknown
|
|||
mysql-5.7 (Ubuntu) |
Fix Released
|
High
|
Lars Tangvald |
Bug Description
Every 10-15 minutes mysql crashes with this error.
ProblemType: Package
DistroRelease: Ubuntu 16.04
Package: mysql-server-5.7 5.7.12-0ubuntu1
ProcVersionSign
Uname: Linux 4.4.0-24-generic x86_64
ApportVersion: 2.20.1-0ubuntu2.1
Architecture: amd64
Date: Fri Jun 10 10:47:34 2016
ErrorMessage: subprocess installed post-installation script returned error exit status 1
InstallationDate: Installed on 2002-01-01 (5279 days ago)
InstallationMedia: Ubuntu 14.04.1 LTS "Trusty Tahr" - Release amd64 (20140722.2)
Logs.var.
Logs.var.
MySQLConf.
MySQLConf.
[mysqld_safe]
syslog
MySQLConf.
[mysqldump]
quick
quote-names
max_allowed_packet = 16M
MySQLConf.
[mysqld_safe]
syslog
MySQLVarLibDirL
ProcCmdline: BOOT_IMAGE=
RelatedPackageV
dpkg 1.18.4ubuntu1.1
apt 1.2.12~
SourcePackage: mysql-5.7
Title: package mysql-server-5.7 5.7.12-0ubuntu1 failed to install/upgrade: subprocess installed post-installation script returned error exit status 1
UpgradeStatus: Upgraded to xenial on 2016-06-10 (4 days ago)
upstart.
Related branches
- MySQL Ubuntu Packagers: Pending requested
-
Diff: 29 lines (+3/-3)2 files modifieddebian/control (+1/-2)
debian/copyright (+2/-1)
summary: |
- package mysql-server-5.7 5.7.12-0ubuntu1 failed to install/upgrade: - subprocess installed post-installation script returned error exit status - 1 + postinst fails when daemon is not running (or is disabled by policy- + rc.d) |
tags: | removed: need-duplicate-check |
Changed in mysql-5.7 (Ubuntu): | |
milestone: | none → ubuntu-16.09 |
Changed in mysql-5.7 (Debian): | |
status: | Unknown → New |
Changed in mysql-5.7 (Ubuntu): | |
status: | Triaged → In Progress |
tags: | added: mysql-sprint |
Changed in mysql-5.7 (Debian): | |
status: | New → Fix Released |
I've discussed this with Lars. The problem is that we need to run mysql_upgrade in the postinst as it is expected that /var/lib/mysql is upgraded when the package is upgraded. However, mysql_upgrade requires the daemon to be running, and the daemon must be restarted after it is finished running. This is tricky to do in a postinst with respect to policy-rc.d.
I think this is the more general case of this specific bug.
We moved mysql_upgrade to the postinst from the upstart service script in 5.7 when we did the systemd work. Otherwise we struggle to restart mysqld after mysql_upgrade has run.
I think the solution is to consider the daemon start/stop for the purposes of mysql_upgrade outside the scope of policy-rc.d, while ensuring that it doesn't appear to be running during that time to anything else. For example, run it with TCP disabled and on a Unix socket in a temporary location only, just for the purpose of mysql_upgrade to talk to it. Then it would effectively be the same as running a version of mysql_upgrade that does not require a running daemon. This special start/stop of mysqld could use start-stop-daemon with a custom configuration to run with TCP disabled and put the pidfile and Unix socket in a temporary location. I'm told that mysqld will fail to start if it cannot get an exclusive lock on specific files inside /var/lib/mysql, so we should be safe from concurrent access issues with a daemon we do not know about.
However, if policy-rc.d means that a daemon remains running when the postinst is running, we will just not be able to run mysql_upgrade. Perhaps we should warn in this case.