package mysql-server-5.7 5.7.13-0ubuntu0.16.04.2 failed to install/upgrade: subprocess installed post-installation script returned error exit status 1

Bug #1605687 reported by Shevek
54
This bug affects 11 people
Affects Status Importance Assigned to Milestone
mysql-5.7 (Ubuntu)
Confirmed
High
Unassigned

Bug Description

shevek@raven:~$ sudo apt-get dist-upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n]
Setting up mysql-server-5.7 (5.7.13-0ubuntu0.16.04.2) ...
Renaming removed key_buffer and myisam-recover options (if present)
insserv: warning: current start runlevel(s) (empty) of script `mysql' overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `mysql' overrides LSB defaults (0 1 6).
mysql_upgrade: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) while connecting to the MySQL server
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.
                          Errors were encountered while processing:
 mysql-server-5.7
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

ProblemType: Package
DistroRelease: Ubuntu 16.04
Package: mysql-server-5.7 5.7.13-0ubuntu0.16.04.2
ProcVersionSignature: Ubuntu 4.4.0-31.50-generic 4.4.13
Uname: Linux 4.4.0-31-generic x86_64
ApportVersion: 2.20.1-0ubuntu2.1
Architecture: amd64
Date: Fri Jul 22 09:36:06 2016
ErrorMessage: subprocess installed post-installation script returned error exit status 1
InstallationDate: Installed on 2015-05-18 (430 days ago)
InstallationMedia: Xubuntu 15.04 "Vivid Vervet" - Release amd64 (20150422.1)
Logs.var.log.daemon.log:

MySQLConf.etc.mysql.conf.d.mysql.cnf: [mysql]
MySQLConf.etc.mysql.conf.d.mysqldump.cnf:
 [mysqldump]
 quick
 quote-names
 max_allowed_packet = 16M
MySQLConf.etc.mysql.mysql.conf.d.mysqld_safe_syslog.cnf:
 [mysqld_safe]
 syslog
MySQLVarLibDirListing: ['debian-5.7.flag', 'mysql', 'ib_logfile1', 'ib_buffer_pool', 'ib_logfile0', 'mysql_upgrade_info', 'sys', 'debian-5.6.flag', 'ibdata1', 'hive', 'auto.cnf', 'performance_schema']
ProcCmdline: BOOT_IMAGE=/vmlinuz-4.4.0-31-generic.efi.signed root=/dev/mapper/xubuntu--vg-root ro noprompt persistent quiet splash vt.handoff=7
RelatedPackageVersions:
 dpkg 1.18.4ubuntu1.1
 apt 1.2.12~ubuntu16.04.1
SourcePackage: mysql-5.7
Title: package mysql-server-5.7 5.7.13-0ubuntu0.16.04.2 failed to install/upgrade: subprocess installed post-installation script returned error exit status 1
UpgradeStatus: Upgraded to xenial on 2016-06-23 (29 days ago)
upstart.mysql.override: manual

Revision history for this message
Shevek (r-launchpad-anarres-org) wrote :
tags: removed: need-duplicate-check
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in mysql-5.7 (Ubuntu):
status: New → Confirmed
Revision history for this message
Ivan (hyllo.ivan) wrote :

Have a look at the following: https://github.com/ankane/groupdate#for-mysql

Could this bug be related to the script that's linked where it says:

   "or copy and paste these statements into a SQL console." ?

Might be unrelated, but if someone's trying to solve this, take a peak...I'm just guessing.

Revision history for this message
Shevek (r-launchpad-anarres-org) wrote :
Download full text (6.9 KiB)

shevek@raven:~$ sudo dpkg --debug=3 --configure mysql-server-5.7
D000001: ensure_diversions: new, (re)loading
D000001: process queue pkg mysql-server-5.7:amd64 queue.len 0 progress 1, try 1
Setting up mysql-server-5.7 (5.7.13-0ubuntu0.16.04.2) ...
D000002: fork/exec /var/lib/dpkg/info/mysql-server-5.7.postinst ( configure 5.7.12-0ubuntu1.1 )
+ . /usr/share/debconf/confmodule
++ '[' '!' '' ']'
++ PERL_DL_NONLAZY=1
++ export PERL_DL_NONLAZY
++ '[' '' ']'
++ exec /usr/share/debconf/frontend /var/lib/dpkg/info/mysql-server-5.7.postinst configure 5.7.12-0ubuntu1.1
+ . /usr/share/debconf/confmodule
++ '[' '!' 1 ']'
++ '[' -z '' ']'
++ exec
++ '[' '' ']'
++ exec
++ DEBCONF_REDIR=1
++ export DEBCONF_REDIR
+ '[' -n '' ']'
+ export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/sbin:/usr/sbin:/bin:/usr/bin
+ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/sbin:/usr/sbin:/bin:/usr/bin
+ ERR_LOGGER='logger -p daemon.err -t mysqld_safe -i'
+ set +e
+ invoke stop
+ pathfind invoke-rc.d
+ OLDIFS='
'
+ IFS=:
+ for p in '$PATH'
+ '[' -x /usr/local/sbin/invoke-rc.d ']'
+ for p in '$PATH'
+ '[' -x /usr/local/bin/invoke-rc.d ']'
+ for p in '$PATH'
+ '[' -x /usr/sbin/invoke-rc.d ']'
+ IFS='
'
+ return 0
+ invoke-rc.d mysql stop
+ set -e
+ case "$1" in
+ mysql_datadir=/usr/share/mysql
+ mysql_statedir=/var/lib/mysql
+ mysql_rundir=/var/run/mysqld
+ mysql_logdir=/var/log/mysql
+ mysql_cfgdir=/etc/mysql
+ mysql_upgradedir=/var/lib/mysql-upgrade
+ mysql_filesdir=/var/lib/mysql-files
+ mysql_keyringdir=/var/lib/mysql-keyring
+ aa-status --enabled
+ apparmor_parser -r -T -W /etc/apparmor.d/usr.sbin.mysqld
+ /usr/share/mysql-common/configure-symlinks install mysql /etc/mysql/mysql.cnf
+ for d in '$mysql_statedir' '$mysql_filesdir' '$mysql_keyringdir' '$mysql_logdir'
+ '[' '!' -d /var/lib/mysql -a '!' -L /var/lib/mysql ']'
+ chown -R mysql:mysql /var/lib/mysql
+ chmod 0700 /var/lib/mysql
+ for d in '$mysql_statedir' '$mysql_filesdir' '$mysql_keyringdir' '$mysql_logdir'
+ '[' '!' -d /var/lib/mysql-files -a '!' -L /var/lib/mysql-files ']'
+ chown -R mysql:mysql /var/lib/mysql-files
+ chmod 0700 /var/lib/mysql-files
+ for d in '$mysql_statedir' '$mysql_filesdir' '$mysql_keyringdir' '$mysql_logdir'
+ '[' '!' -d /var/lib/mysql-keyring -a '!' -L /var/lib/mysql-keyring ']'
+ chown -R mysql:mysql /var/lib/mysql-keyring
+ chmod 0700 /var/lib/mysql-keyring
+ for d in '$mysql_statedir' '$mysql_filesdir' '$mysql_keyringdir' '$mysql_logdir'
+ '[' '!' -d /var/log/mysql -a '!' -L /var/log/mysql ']'
+ chown -R mysql:mysql /var/log/mysql
+ chmod 0700 /var/log/mysql
+ set +e
+ chown -R 0:0 /usr/share/mysql
+ touch /var/log/mysql/error.log
+ chown -R mysql:adm /var/log/mysql
+ chmod 0750 /var/log/mysql
+ chmod 0640 /var/log/mysql/error.log
+ set -e
+ db_set mysql-server/postrm_remove_database false
+ _db_cmd 'SET mysql-server/postrm_remove_database' false
+ _db_internal_IFS='
'
+ IFS=' '
+ printf '%s\n' 'SET mysql-server/postrm_remove_database false'
+ IFS='
'
+ IFS='
'
+ read -r _db_internal_line
+ RET='10 mysql-server/postrm_remove_database doesn'\''t exist'
+ case ${_db_internal_line%%[ ]*} in
+ return 10
+ true
+ dpkg --compare-versions 5.7....

Read more...

Revision history for this message
Shevek (r-launchpad-anarres-org) wrote :

The problem is that invoke-rc.d is not invoking mysql's start-stop script properly. Swapping 'invoke-rc.d' for 'service' in invoke() makes the script succeed. My system is now correctly configured.

Revision history for this message
Shevek (r-launchpad-anarres-org) wrote :

When I say "invoke-rc.d is not working", I mean that a service status on the service suggests that invoke-rc.d did nothing whatsoever. No errors, nothing. The mysql service didn't even notice that invoke-rc.d had been run.

Revision history for this message
Chris Siebenmann (cks) wrote :

When this happened to us during a mysql-server upgrade, the root
cause is that we had mysql (the server) disabled, ie 'systemctl disable
mysql'. When you do this, 'invoke-rc.d mysql start' winds up doing nothing
and not starting the server, which causes mysql_upgrade to fail because
it requires a running server.

Explicitly starting mysql before you do the upgrade doesn't help,
because the mysql-server-5.7 postinst script starts out by shutting it
down. What does work around the issue is re-enabling mysql beforehand:
'systemctl enable mysql', do the upgrade, then 'systemctl disable mysql;
systemctl stop mysql'.

(Invoke-rc.d does not directly ask systemd for the status of mysql.
Instead it looks at /etc/rc5.d/ S* and K* symlinks, which systemctl
manipulates for systemd services that also have an /etc/init.d
script, which mysql does. Finding this takes tracing through a lot
of layers.)

A correct bugfix for our issue would be for the mysql-server postinst
script to unconditionally start mysql using eg 'service mysql start',
instead of relying on invoke-rc.d. The ideal sequence would be to
explicitly start mysql, run mysql_upgrade, shut mysql down, and then run
'invoke-rc.d mysql start' to restart it only if it's been enabled.

Revision history for this message
Shevek (r-launchpad-anarres-org) wrote :

@cks You are correct, I also have the mysql service disabled, which explains the behaviour of rc.d. Editing the postinst script to use service instead of invoke-rc.d did fix it, though.

Changed in mysql-5.7 (Ubuntu):
importance: Undecided → High
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.