Comment 3 for bug 1863318

Revision history for this message
Hans Rakers (hrak) wrote : Re: package mysql-server-5.7 5.7.29-0ubuntu0.16.04.1 failed to install/upgrade: subprocess installed post-installation script returned error exit status 1

I just ran into this same issue with 5.7.29-0ubuntu0.16.04.1. It is caused by a race condition.

It is a rather large MySQL database, so stopping & starting up the daemon takes some time. Tried 'apt-get -f install' multiple times to no avail.

After going over the code in /var/lib/dpkg/info/mysql-server-5.7.postinst, i managed to "fix" it by adding a 'sleep 5' at line 317. Sleep 3 didn't cut it, it had to be sleep 5 :D

Like so:

    if ! test_sysmaint_access; then
      invoke stop
      set_mysql_pw "debian-sys-maint" "$pass"
      invoke start
      echo "sleeping 5 secs"
      sleep 5
    fi
    # mysql_upgrade returns exit status 2 if the database is already upgraded
    # (LP: #1566406) so ignore its exit status if it is 2.
    result=0
    mysql_upgrade --defaults-file=/etc/mysql/debian.cnf || result=$?

The way to finally get rid of these issues is to add something in this script to check if the instance is ready for connections before starting mysql_upgrade.