Comment 37 for bug 973951

Revision history for this message
Sebastian Audet (smaudet) wrote :

Well, I had this issue too, looks like launchpad doesn't let me submit a bug.

My 'fix' is less of a fix, but here's my feedback:

'Ubuntu version: 12.04.2 LTS (Kubuntu)
Specific package version: 5.5.22-0ubuntu1
Expected behavior: Install should succeed, job should start
Actual behavior: Install does not succeed, job cannot start

There is an issue with the upstart script in /etc/init/mysql.conf. Please find attached my 'fixes'. Please note that these fixes contain extra notes, and are not considered patch material, e.g. I have commented out offending code, and I have commented out a function which needs to be included.

In summary:

Problem #1
mysqld_get_param does not exist. This must be included, or replaced with the line used in the file.

Problem #2
An assumption is made that the data dir exists on a seperate partition. If this is not the case, the upstart script will fail to launch.

Problem #3
Thanks to these issue, the mysql-server cannot be configured from the package manager, as the upstart job fails, causing the install to fail to succeed.

Result:
After I made the changes seen in the attached file, the problems went away. This file needs some polish however, including detecting whether or not the user has a seperate partition or not.'

my /etc/init/mysql.conf (there are/were multiple issues):

# MySQL Service

description "MySQL Server"
author "Mario Limonciello <email address hidden>"

start on runlevel [2345]
stop on starting rc RUNLEVEL=[016]

respawn
respawn limit 2 5

env HOME=/etc/mysql
umask 007

# The default of 5 seconds is too low for mysql which needs to flush buffers
kill timeout 300

#mysqld_get_param() {
# /usr/sbin/mysqld --print-defaults \
# | tr " " "\n" \
# | grep -- "--$1" \
# | tail -n 1 \
# | cut -d= -f2
#}

pre-start script

    # priority can be overriden and "-s" adds output to stderr
    ERR_LOGGER="logger -p daemon.err -t /etc/init/mysql.conf -i"
    #Sanity checks
    [ -r $HOME/my.cnf ]
    [ -d /var/run/mysqld ] || install -m 755 -o mysql -g root -d /var/run/mysqld
    /lib/init/apparmor-profile-load usr.sbin.mysqld
    # check for diskspace shortage
    datadir=`/usr/sbin/mysqld --print-defaults | tr " " "\n" | grep -- "--datadir" | tail -n 1 | cut -d= -f2`
# if LC_ALL=C BLOCKSIZE= df --portability $datadir/. | tail -n 1 | awk '{ exit ($4<4096) }'; then
# echo "$0: ERROR: The partition with $datadir is too full!" >&2
# echo "ERROR: The partition with $datadir is too full!" | $ERR_LOGGER
# exit 1
# fi
end script

exec /usr/sbin/mysqld

post-start script
   for i in `seq 1 30` ; do
        /usr/bin/mysqladmin --defaults-file="${HOME}"/debian.cnf ping && {
            exec "${HOME}"/debian-start
            # should not reach this line
            exit 2
        }
        statusnow=`status`
        if echo $statusnow | grep -q 'stop/' ; then
            exit 0
        elif echo $statusnow | grep -q 'respawn/' ; then
            exit 1
        fi
        sleep 1
    done
    exit 1
end script