How can I know if Mysql Crashed or stopped gracefully

2009-10-27 Thread Bryan Cantwell
I have an environment where upon boot of a machine I need to know if 
mysql shutdown nicely or if it crashed.
How can I know for sure which was the case so that I can take action if 
needed?
I notice that issuing a reboot or shutdown -r now command, (in Linux) 
that the 'service mysql stop'  is never run... it just seems to catch 
the sig 15 and does its own shutdown...


I have scripted in the stop section of my init script to touch a file 
that I look for on restart, but if the stop is never executed on 
reboot/shutdown, then I have a problem.


Thanks for the help,
Bryancan

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org



Re: How can I know if Mysql Crashed or stopped gracefully

2009-10-27 Thread Johan De Meersman
Signal 15 is pretty much equal to a regular shutdown, except that if your
shutdown script doesn't run, you may be left with lockfiles, pidfiles and
the like.

A crash would most likely be visible in the logfile, and even if it isn't
(machine loses power), your log should show innodb running a recovery
procedure at startup.


On Tue, Oct 27, 2009 at 3:51 PM, Bryan Cantwell bcantw...@firescope.comwrote:

 I have an environment where upon boot of a machine I need to know if mysql
 shutdown nicely or if it crashed.
 How can I know for sure which was the case so that I can take action if
 needed?
 I notice that issuing a reboot or shutdown -r now command, (in Linux) that
 the 'service mysql stop'  is never run... it just seems to catch the sig 15
 and does its own shutdown...

 I have scripted in the stop section of my init script to touch a file that
 I look for on restart, but if the stop is never executed on reboot/shutdown,
 then I have a problem.

 Thanks for the help,
 Bryancan

 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:http://lists.mysql.com/mysql?unsub=vegiv...@tuxera.be




Re: How can I know if Mysql Crashed or stopped gracefully

2009-10-27 Thread Todd Lyons
On Tue, Oct 27, 2009 at 7:51 AM, Bryan Cantwell bcantw...@firescope.com wrote:
 I notice that issuing a reboot or shutdown -r now command, (in Linux) that
 the 'service mysql stop'  is never run... it just seems to catch the sig 15
 and does its own shutdown...
 I have scripted in the stop section of my init script to touch a file that I
 look for on restart, but if the stop is never executed on reboot/shutdown,
 then I have a problem.

What distro?  Which version of mysql?  My comments below apply to our
InnoDB heavy CentOS systems.

Older versions of mysql (5.0.x on our CentOS machines) wait 60 seconds
for the mysqld process to completely die.  If mysql has a lot of data
to flush to disk, it can take longer than that 60 seconds.  The init
script assumes that the kill command didn't succeed, it prints out
FAILED, and the system shutdown process moves on to the next init
script.  Near the end of the system shutdown process, the shutdown
script issues a final SIGKILL to remaining running processes.  If
mysqld didn't finish flushing that data before this final KILL signal,
the mysqld process is killed instantly and you have an unclean
shutdown.

One quick solution is to manually stop mysql, watching to see when the
process finally goes away (top, ps, etc), then do your shutdown -r
now.

Modern versions of mysql (5.1.x) seem to handle this better because it
waits as long as it takes for mysqld to shut down properly or to start
up (and accept connections).  At least in my testing so far, I've not
hit a timeout or received an incorrect OK or FAILED message in the
5.1.x series.

-- 
Regards...  Todd
The best thing about pair programming is that you have the perfect
audience for your genius.  -- Kent Beck

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org