MySQL corruption every time the DB is restarted
I am encountering data corruption every time MySQL is restarted. The restart is done through scripts and I encounter the following error:
myisamchk: MyISAM file /global/mysql/mysql/db.MYI
myisamchk: warning: 1 client is using or hasn't closed the table
properly
MyISAM-table '/global/mysql/mysql/db.MYI' is usable but should be fixed
After I googled, I found that running myisamchk on the table was the most commonly provided solution and tried it:
bash-2.05# /opt/mysql/mysql/bin/myisamchk -r /global/mysql/mysql/db.MYI
- recovering (with sort) MyISAM-table '/global/mysql/mysql/db.MYI'
Data records: 6
- Fixing index 1
- Fixing index 2
bash-2.05# echo $?
0
but the problem resurfaces every time the DB is restarted!! 
Got ideas?

And now, young Padawan, you are ready to try http://postgresql.org :)
"I'm using MySql"
"yes"
"and I'm having problems"
"you already said that"
Posted by Dick Davies on March 17, 2008 at 04:43 PM IST #
You might turn up the logging to see if cluster is giving MySQL a chance to come down cleanly or if it is sending SIGKILL or something like that. Another alternative is to use the innodb engine for you tables. It will recover cleanly from hard shutdowns.
Posted by Brian on March 17, 2008 at 07:06 PM IST #
Brian,
Thanks for the suggestion. You're spot on. The script follows a complex heuristic and if proper shutdown of database doesn't complete within a specified time out period, it sends a sigkill. Strangely, the data corruption is noticed only for 5.0.37 while 5.0.45 seems to handle it gracefully.
Posted by Brian on March 17, 2008 at 11:16 PM IST #