The MySQL upstart job does not monitor the mysqld process anymore. Instead it is shut down by mysqladmin tool in the postStop phase. Under high load, upstart may send a KILL signal to the mysql daemon, which may cause data corruption.

svn path=/nixos/trunk/; revision=31621
This commit is contained in:
Sander van der Burg 2012-01-18 15:01:44 +00:00
parent 5d12152b13
commit d4b6aa3553

View File

@ -156,12 +156,9 @@ in
mkdir -m 0700 -p ${cfg.pidDir}
chown -R ${cfg.user} ${cfg.pidDir}
'';
exec = "${mysql}/libexec/mysqld --defaults-extra-file=${myCnf} ${mysqldOptions}";
${mysql}/libexec/mysqld --defaults-extra-file=${myCnf} ${mysqldOptions} &
postStart =
''
# Wait until the MySQL server is available for use
count=0
while [ ! -e /tmp/mysql.sock ]
@ -179,14 +176,14 @@ in
if [ -f /tmp/mysql_init ]
then
# Create initial databases
${concatMapStrings (database:
''
# Create initial databases
if ! test -e "${cfg.dataDir}/${database.name}"; then
echo "Creating initial database: ${database.name}"
( echo "create database ${database.name};"
echo "use ${database.name};"
if [ -f "${database.schema}" ]
then
cat ${database.schema}
@ -198,17 +195,16 @@ in
fi
'') cfg.initialDatabases}
# Execute initial script
${optionalString (cfg.initialScript != null)
''
# Execute initial script
cat ${cfg.initialScript} | ${mysql}/bin/mysql -u root -N
''}
# Change root password
${optionalString (cfg.rootPassword != null)
''
# Change root password
( echo "use mysql;"
echo "update user set Password=password('$(cat ${cfg.rootPassword})') where User='root';"
echo "flush privileges;"
@ -219,6 +215,8 @@ in
fi
'';
postStop = "${mysql}/bin/mysqladmin --user=root --password=\"$(cat ${cfg.rootPassword})\" shutdown";
# !!! Need a postStart script to wait until mysqld is ready to
# accept connections.