hironomiu's Blog

こそっと書いていきます。twitter_id:hironomiu

mysql error logの肥大化

とあるサービスのエンジニアから開発機のDisk使用量のアラートが上がってると問い合わせがきたので

開発機のDiskの状況を調べてたらこんな状況だった。

[xxxxxxxxx]# df

Filesystem 1K-ブロック 使用 使用可 使用% マウント位置
/dev/sda2 5820012 1139920 4379680 21% /
/dev/sda5 125199736 108222064 10515128 92% /var
/dev/sda1 101086 18745 77122 20% /boot
tmpfs 2024808 0 2024808 0% /dev/shm

/varが確かに92%を超えていた。
どこがそんなに食ってるんだろうと調べると、とあるmysqlインスタンスが75Gも使っていたのが判明。
確認するとerror logがすごいことに。

  • rw-rw---- 1 mysql root 59928108333 12月 22 13:58 xxxxxxxx.err

中身をtailで見ると

InnoDB: but the tablespace does not exist or is just being dropped.
111222 13:59:52 InnoDB: Error: trying to access tablespace 11113 page no. 3,
InnoDB: but the tablespace does not exist or is just being dropped.
111222 13:59:52 InnoDB: Error: trying to access tablespace 11097 page no. 3,
InnoDB: but the tablespace does not exist or is just being dropped.
111222 13:59:52 InnoDB: Error: trying to access tablespace 11113 page no. 3,
InnoDB: but the tablespace does not exist or is just being dropped.
111222 13:59:52 InnoDB: Error: trying to access tablespace 11097 page no. 3,
InnoDB: but the tablespace does not exist or is just being dropped.

ひたすらerrorを吐き続けていた。
通常のrestartが出来ないのでkill -9で該当プロセスをkill

[xxxxxxxxx]# /etc/init.d/mysql_xxxxx restart
Shutting down MySQL...............................................................................................................................................

★ここで別ターミナルでkill

SUCCESS!
Starting MySQL..... SUCCESS!

改めてstopし調査用に退避するのも何なのでエイっとerror logは削除
起動しerror logの中身を見ると

[xxxxxxxxx]# cat mysql51-dev1.ycc.ecnavi.info.err
111222 14:06:17 mysqld_safe A mysqld process already exists

ちょっと気持ち悪いのでもう一回restartを。

111222 14:28:34 InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
InnoDB: Last MySQL binlog file position 0 246733814, file name ./mysql51-dev1-bin.000055
111222 14:28:34 InnoDB Plugin 1.0.6 started; log sequence number 56840114350
111222 14:28:34 [Note] Recovering after a crash using mysql51-dev1-bin
111222 14:28:34 [Note] Starting crash recovery...
111222 14:28:34 [Note] Crash recovery finished.
111222 14:28:34 [Note] Event Scheduler: Loaded 0 events
111222 14:28:34 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.1.42-community-log' socket: '/var/lib/mysql_au_shopping/mysql.sock' port: 3313 MySQL Community Server (GPL)


ちゃんとクラッシュリカバリもしてくれて無事起動しerror logの肥大化も収まってくれた。

このバグの可能性が高い感じ

http://bugs.mysql.com/bug.php?id=38901