今天早上,下载频道的数据库压力突然变大,线程数在700上下波动,大量线程处于Locked状态。这些线程主要是对userday_money和source_uesrdown的查询,这两个表目前的数据都超过2百万,难道是数据量太大了。
看看MySQL日志在说吧,还好,日志告诉了我查询慢的原因:
071221 11:12:12 [ERROR] Got error 127 when reading table './download_utf8/source_uesrdown'
071221 11:33:32 [ERROR] Got error 134 when reading table './download_utf8/userday_money'
使用 perror 127 134 查出上边错误的描述:
MySQL error code 127: Record-file is crashed
MySQL error code 134: Record was already deleted (or record file crashed)
应该是Table表文件有坏块了:
进入MySQL的命令行,运行 Repair Table source_uesrdown ; Repair Table userday_money;
.........
大约半小时后,终于完成了修复任务,显示如下提示:
+-----------------------------+--------+----------+----------------------------------------------------------+
| Table | Op | Msg_type | Msg_text |
+-----------------------------+--------+----------+----------------------------------------------------------+
| download_utf8.userday_money | repair | info | Wrong bytesec: 172- 4- 45 at 77805716; Skipped |
| download_utf8.userday_money | repair | info | Wrong block with wrong total length starting at 77843424 |
| download_utf8.userday_money | repair | warning | Number of rows changed from 2951821 to 2951819 |
| download_utf8.userday_money | repair | status | OK |
+-----------------------------+--------+----------+----------------------------------------------------------+
修复后MySQL的线程降到了100个以下,频道也正常了.
现在还不清楚是什么原因导致表文件出现坏块,只能定期Repair了。
参考资料:
http://dev.mysql.com/doc/refman/5.0/en/repair.html
http://dev.mysql.com/doc/refman/5.0/en/general-thread-states.html