Bug #49822 /etc/init.d/mysql can't stop mysqld properly
Submitted: 19 Dec 2009 11:51 Modified: 19 Dec 2009 14:23
Reporter: Sadao Hiratsuka (Basic Quality Contributor) Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: General Severity:S2 (Serious)
Version:5.5.0-m2 OS:Linux (RHEL5.4)
Assigned to: CPU Architecture:Any
Tags: init.d, qc, shutdown

[19 Dec 2009 11:51] Sadao Hiratsuka
Description:
/etc/init.d/mysql can't stop mysqld properly.

How to repeat:
[root@armada mysql]# service mysql start
Starting MySQL..                                           [  OK  ]
[root@armada mysql]# service mysql stop
Shutting down MySQL.The server quit without updating PID fi[Failed]ar/lib/mysql/armada.pid).

Suggested fix:
<<< /etc/init.d/mysql >>>

  'stop')
    # Stop daemon. We use a signal here to avoid having to know the
    # root password.

    if test -s "$mysqld_pid_file_path"
    then
      mysqld_pid=`cat "$mysqld_pid_file_path"`

      if (kill -9 $mysqld_pid 2>/dev/null)
##################################################
# I think the above line should be 'kill -0' (MySQL 5.1 does 'kill -0')
##################################################
      then
        echo $echo_n "Shutting down MySQL"
        kill $mysqld_pid
        # mysqld should remove the pid file when it exits, so wait for it.
        wait_for_pid removed "$mysqld_pid" "$mysqld_pid_file_path"; return_value=$?
      else
        log_failure_msg "MySQL server process #$mysqld_pid is not running!"
        rm "$mysqld_pid_file_path"
      fi
[19 Dec 2009 13:02] Sadao Hiratsuka
kill -9 is dangerous for MyISAM storage engine.
So I changed severity to S2.
[19 Dec 2009 14:23] Valeriy Kravchuk
This is a duplicate of bug #49772.