Bug #30378 mysql.server needs to skip wait_for_pid() when mysqld isn't running
Submitted: 12 Aug 2007 14:39 Modified: 15 Apr 2008 1:58
Reporter: Matthew Lord Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:all OS:Any
Assigned to: Chad MILLER CPU Architecture:Any
Tags: bfsm_2007_08_16, drbd, init, mysql.server

[12 Aug 2007 14:39] Matthew Lord
Description:
If mysqld crashes or is killed abruptly it will leave the pid_file around w/o
the running process which causes wait_for_pid() to wait service_startup_timeout 
seconds (900 seconds by default).

This causees problems for things like Heartbeat/DRBD as you want to failover
quickly.

How to repeat:
killall -9 mysqld_safe
killall -9 mysqld

/etc/init.d/mysql stop

Suggested fix:
We need to first verify that the process id is actually running before we call
wait_for_pid removed.  If it's not then we can simply print the error message
that the PID couldn't be killed.  Here's an example:

mysqlmanager_pid=`cat $pid_file`
echo $echo_n "Shutting down MySQL"
if kill $mysqlmanager_pid
then
# mysqlmanager should remove the pid_file when it exits, so wait for it.
wait_for_pid removed; return_value=$?
else
# it seems mysqlmanager is not running
log_failure_msg "could not kill MySQL with PID $mysqlmanager_pid"
return_value=1;
fi
[19 Mar 2008 20:45] Timothy Smith
Minor comments:
- use $verb instead of $1
- see if putting "case $verb" inside the "if kill -0 ..." reduces code duplication
[19 Mar 2008 22:14] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/44261

ChangeSet@1.2586, 2008-03-19 18:13:56-04:00, cmiller@zippy.cornsilk.net +1 -0
  Bug#30378: mysql.server needs to skip wait_for_pid() when mysqld \
  	isn't running
  
  Pass the process id of the manager as a parameter to "wait_for_pid"
  and if the manager isn't running, then do not continue to wait.
  
  Also, capture the error message of our process-existence test, 
  "kill -0", as we expect errors and shouldn't pass them to the user.  
  Additionally, be a bit more descriptive of what the problem is.
[26 Mar 2008 18:33] Chad MILLER
Queued to 5.0-build, 5.1-build, and 6.0-build.
[27 Mar 2008 22:03] Bugs System
Pushed into 5.1.24-rc
[27 Mar 2008 22:11] Bugs System
Pushed into 5.0.60
[28 Mar 2008 11:10] Bugs System
Pushed into 6.0.5-alpha
[15 Apr 2008 1:58] Paul DuBois
Noted in 5.0.60, 5.1.24, 6.0.5 changelogs.

An orphaned PID file from a no-longer-running process could cause
mysql.server to wait for that process to exit even though it does not
exist.