From 03540746184bced3f16e02cd047b1af97b9ed61b Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 17 Dec 2009 19:38:27 +0000 Subject: [PATCH] Stop waiting during "service mysqld start" if mysqld_safe exits --- mysql.init | 45 +++++++++++++++++++++++++-------------------- mysql.spec | 8 +++++++- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/mysql.init b/mysql.init index 327ed8b..3656a4a 100644 --- a/mysql.init +++ b/mysql.init @@ -72,29 +72,34 @@ start(){ /usr/bin/mysqld_safe --datadir="$datadir" --socket="$socketfile" \ --pid-file="$mypidfile" \ --user=mysql >/dev/null 2>&1 & - ret=$? - # Spin for a maximum of N seconds waiting for the server to come up. + safe_pid=$! + # Spin for a maximum of N seconds waiting for the server to come up; + # exit the loop immediately if mysqld_safe process disappears. # Rather than assuming we know a valid username, accept an "access # denied" response as meaning the server is functioning. - if [ $ret -eq 0 ]; then - STARTTIMEOUT=60 - while [ $STARTTIMEOUT -gt 0 ]; do - RESPONSE=`/usr/bin/mysqladmin --socket="$socketfile" --user=UNKNOWN_MYSQL_USER ping 2>&1` && break - echo "$RESPONSE" | grep -q "Access denied for user" && break - sleep 1 - let STARTTIMEOUT=${STARTTIMEOUT}-1 - done - if [ $STARTTIMEOUT -eq 0 ]; then - echo "Timeout error occurred trying to start MySQL Daemon." - action $"Starting $prog: " /bin/false - ret=1 - else - action $"Starting $prog: " /bin/true - fi - else - action $"Starting $prog: " /bin/false + ret=0 + STARTTIMEOUT=120 + while [ $STARTTIMEOUT -gt 0 ]; do + RESPONSE=`/usr/bin/mysqladmin --socket="$socketfile" --user=UNKNOWN_MYSQL_USER ping 2>&1` && break + echo "$RESPONSE" | grep -q "Access denied for user" && break + if ! /bin/kill -0 $safe_pid 2>/dev/null; then + echo "MySQL Daemon failed to start." + ret=1 + break + fi + sleep 1 + let STARTTIMEOUT=${STARTTIMEOUT}-1 + done + if [ $STARTTIMEOUT -eq 0 ]; then + echo "Timeout error occurred trying to start MySQL Daemon." + ret=1 + fi + if [ $ret -eq 0 ]; then + action $"Starting $prog: " /bin/true + touch /var/lock/subsys/mysqld + else + action $"Starting $prog: " /bin/false fi - [ $ret -eq 0 ] && touch /var/lock/subsys/mysqld return $ret } diff --git a/mysql.spec b/mysql.spec index b8726bd..91661ba 100644 --- a/mysql.spec +++ b/mysql.spec @@ -1,6 +1,6 @@ Name: mysql Version: 5.1.41 -Release: 1%{?dist} +Release: 2%{?dist} Summary: MySQL client programs and shared libraries Group: Applications/Databases URL: http://www.mysql.com @@ -649,9 +649,15 @@ fi %{_mandir}/man1/mysql_client_test.1* %changelog +* Thu Dec 17 2009 Tom Lane 5.1.41-2 +- Stop waiting during "service mysqld start" if mysqld_safe exits +Resolves: #544095 + * Mon Nov 23 2009 Tom Lane 5.1.41-1 - Update to MySQL 5.1.41, for various fixes described at http://dev.mysql.com/doc/refman/5.1/en/news-5-1-41.html + including fixes for CVE-2009-4019 +Related: #540906 - Don't set old_passwords=1; we aren't being bug-compatible with 3.23 anymore Resolves: #540735