cannot upgrade mysql server package

Bug #1909043 reported by Poldi
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
mysql-8.0 (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

I'm on
Description: Ubuntu 20.04.1 LTS
Release: 20.04

Package
mysql-server:
  Installed: 8.0.22-0ubuntu0.20.04.3
  Candidate: 8.0.22-0ubuntu0.20.04.3
  Version table:
 *** 8.0.22-0ubuntu0.20.04.3 500
        500 http://mirror.intergrid.com.au/ubuntu focal-updates/main amd64 Packages
        500 http://mirror.intergrid.com.au/ubuntu focal-updates/main i386 Packages
        500 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu focal-security/main i386 Packages
        100 /var/lib/dpkg/status
     8.0.19-0ubuntu5 500
        500 http://mirror.intergrid.com.au/ubuntu focal/main amd64 Packages
        500 http://mirror.intergrid.com.au/ubuntu focal/main i386 Packages

Every ubuntu update hangs/fail due to a problem with the mysql-server package.

I can reproduce the issue by running
>> sudo dpkg --configure -a
--------------------------------------
Setting up mysql-server-8.0 (8.0.22-0ubuntu0.20.04.3) ...
mysqld will log errors to /var/log/mysql/error.log
mysqld is running as pid 3977
Job for mysql.service failed because a timeout was exceeded.
See "systemctl status mysql.service" and "journalctl -xe" for details.
invoke-rc.d: initscript mysql, action "start" failed.
● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: activating (auto-restart) (Result: timeout) since Thu 2020-12-17 12:19:37 AEDT; 10ms ago
    Process: 4120 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
    Process: 4154 ExecStart=/usr/sbin/mysqld (code=exited, status=0/SUCCESS)
   Main PID: 4154 (code=exited, status=0/SUCCESS)

Dec 17 12:19:38 mail systemd[1]: mysql.service: Scheduled restart job, restart counter is at 1.
Dec 17 12:19:38 mail systemd[1]: Stopped MySQL Community Server.
Dec 17 12:19:38 mail systemd[1]: Starting MySQL Community Server...
dpkg: error processing package mysql-server-8.0 (--configure):
 installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-8.0; however:
  Package mysql-server-8.0 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 mysql-server-8.0
 mysql-server
-------------------------------------------------------------

>> sudo dpkg-reconfigure mysql-server-8.0
--------------------------
/usr/sbin/dpkg-reconfigure: mysql-server-8.0 is broken or not fully installed
------------------------------

>> sudo apt policy mysql-server-8.0
-------------------------------------------------------
mysql-server-8.0:
  Installed: 8.0.22-0ubuntu0.20.04.3
  Candidate: 8.0.22-0ubuntu0.20.04.3
  Version table:
 *** 8.0.22-0ubuntu0.20.04.3 500
        500 http://mirror.intergrid.com.au/ubuntu focal-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages
        100 /var/lib/dpkg/status
     8.0.19-0ubuntu5 500
        500 http://mirror.intergrid.com.au/ubuntu focal/main amd64 Packages
-------------------------------------------------------------------

>> sudo dpkg -l mysql-server-8.0
-----------------------------------------
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-================-=======================-============-========================================================
iF mysql-server-8.0 8.0.22-0ubuntu0.20.04.3 amd64 MySQL database server binaries and system database setup
------------------------------------------

>> sudo apt install --reinstall mysql-server-8.0
----------------------------------------
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 to upgrade, 0 to newly install, 1 to reinstall, 0 to remove and 0 not to upgrade.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
E: Internal Error, No file name for mysql-server-8.0:amd64
-------------------------------------------

>> sudo apt install --reinstall mysql-server
-------------------------------------------------
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 to upgrade, 0 to newly install, 1 to reinstall, 0 to remove and 0 not to upgrade.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
E: Internal Error, No file name for mysql-server:amd64
---------------------------------------------------

>> sudo dpkg -V mysql-server-8.0
------------------------------
??5?????? c /etc/apparmor.d/usr.sbin.mysqld
??5?????? c /etc/mysql/mysql.conf.d/mysqld.cnf
---------------------------------

ProblemType: Bug
DistroRelease: Ubuntu 20.04
Package: mysql-server 8.0.22-0ubuntu0.20.04.3
ProcVersionSignature: Ubuntu 5.4.0-58.64-generic 5.4.73
Uname: Linux 5.4.0-58-generic x86_64
ApportVersion: 2.20.11-0ubuntu27.14
Architecture: amd64
CasperMD5CheckResult: skip
Date: Wed Dec 23 11:51:33 2020
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: False
PackageArchitecture: all
SourcePackage: mysql-8.0
UpgradeStatus: Upgraded to focal on 2020-10-24 (59 days ago)
modified.conffile..etc.apparmor.d.usr.sbin.mysqld: [modified]
modified.conffile..etc.mysql.mysql.conf.d.mysqld.cnf: [modified]
mtime.conffile..etc.apparmor.d.usr.sbin.mysqld: 2017-01-30T16:55:00.692188
mtime.conffile..etc.mysql.mysql.conf.d.mysqld.cnf: 2020-12-17T10:03:25.429047

Revision history for this message
Poldi (poldi) wrote :
Revision history for this message
Paride Legovini (paride) wrote :

Hello Poldi and thanks for this bug report. It seems that mysqld can't notify systemd it started because it can't connect to the notification socket:

2020-12-23T00:42:48.986520Z 0 [Warning] [MY-011807] [Server] Failed to connect to systemd notification socket named /run/systemd/notify. Error: 'Permission denied'

The AppArmor profile shipped with mysql-server-8.0 has a specific rule to allow mysqld to connect to /run/systemd/notify:

# Allow systemd notify messages
  /{,var/}run/systemd/notify w,

however this is missing from the AppArmor profile attached to this bug report. The bug description shows that the profile has been manually modified:

modified.conffile..etc.apparmor.d.usr.sbin.mysqld: [modified]
mtime.conffile..etc.apparmor.d.usr.sbin.mysqld: 2017-01-30T16:55:00.692188

This is the root of the problem. Purging mysql-server-8.0 (apt purge) and reinstalling it should reinstall the correct AppArmor profile (careful with your existing databases!).

I'm setting this bug report to Incomplete for the moment. If you agree this is a local configuration issue rather than a bug please set its status to Invalid. If you still believe this is a bug in Ubuntu please follow-up with you reasoning and set the bug status back to New, we'll look at it again. Thanks!

Changed in mysql-8.0 (Ubuntu):
status: New → Incomplete
Revision history for this message
Poldi (poldi) wrote :

Thanks for the quick response.

Not sure how/why the profile would have been modified and given I know nothing about AppArmor I assume this happened during one of the previous updates/upgrades.

Other than reinstalling do you have any other suggestions on how I can get past this?
Thanks

Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

Aside from reinstalling the package, you can try to overwrite your current apparmor profile with the one that is shipped by default in the package. Something like the following:

# wget https://launchpad.net/~ubuntu-security-proposed/+archive/ubuntu/ppa/+build/20337434/+files/mysql-server-8.0_8.0.22-0ubuntu0.20.04.3_amd64.deb
# dpkg-deb -x mysql-server-8.0_8.0.22-0ubuntu0.20.04.3_amd64.deb mysql
# cp mysql/etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/
# apparmor_parser -r /etc/apparmor.d/usr.sbin.mysqld

You will need to install the apparmor-utils package in order to get the "apparmor_parser" program. Also, bear in mind that this will *overwrite* your existing /etc/apparmor.d/usr.sbin.mysqld file! Make a backup of it if you want.

Revision history for this message
Poldi (poldi) wrote :

Thank you for your detailed and correct instructions.

Updates now complete without errors.

Thanks,
Leo

Revision history for this message
Paride Legovini (paride) wrote :

Glad to know it worked. I'm setting the status of this bug report to Invalid, as the issue was caused by a local configuration problem rather than by a bug in Ubuntu. Should you think this is not the whole picture and that there is actually a bug in Ubuntu here please change the status back to New and comment back, we'll look at it again. Thanks!

Changed in mysql-8.0 (Ubuntu):
status: Incomplete → Invalid
To post a comment you must log in.