views:

952

answers:

2

When I say sudo /etc/init.d/mysql restart on Ubuntu 8.04.2 sometimes there remains a "mysql_safe" process eating 99% of cpu. Making the machine practically inusable.

Is there a better way to restart mysql? I thought about writing a script:

sudo /etc/init.d/mysql stop
sleep 10
sudo killall mysql_safe
sudo /etc/init.d/mysql start

But this would be a evil workaround. (And the script is just a quick shot)

I googled and found that mysql_safe is a wrapper script which starts mysqld, and makes sure it gets restarted if it should die. So there should be a better way to restart the thing.

I googled that this is a common problem in this ubuntu version. Is debian / ubuntu doing it wrong at this point? The init.d script looks quite sophisticated and it deals with mysql_safe also, but my skills are not good enough to understand it fully. But this would be the best place to improve. This is a paste of the version on my machine (which is untouched): http://pastie.org/421938

I found many hints but I would like this resolved to a certain degree of reliability for production servers.

EDIT:

It seems to be exactly this unsolved bug: https://bugs.launchpad.net/ubuntu/+source/mysql-dfsg-5.0/+bug/105457

Maybe it is this bug from the mysql site: http://bugs.mysql.com/bug.php?id=36550

This seems related or identical: http://forum.slicehost.com/comments.php?DiscussionID=1000

Some people talk of a race condition with 2 instances of mysql_safe. Others suggest commentiong out the sanity check in the startup script.

Karl

+1  A: 

I would try to figure out what is causing the CPU issue, rather than investigate how to re-write the startup script. The startup script is fairly standard and should work well in a production environment.

jonstjohn
It was a clean install on a fresh system, no config changes, and it is also on some bug lists. I added links to the question above. I don't know how to repeat the behaviour but it was clearly there.
Karl Thorwald
I supose the loop is caused by an infinite loop in the mysql_safe shell script. It was suggested by some people to insert a sleep command into the script but this alone would not remove the bug
Karl Thorwald
A: 

Does it goes up to 99%CPU on restarting the service, or you are trying to restart the service because it got stuck at 99% CPU?

First would be necessary to know if it's script or mysql caused.

:D

Andor
I regret I am not able to reproduce the issue at the present. From my memory I can say that the process who consumed all the resources was mysql_safe
Karl Thorwald
but mysql was running fine and then went 99%CPU when running the script, or you where running the script because MySQL was 99%CPU and you wanted to restart it? :)
Andor