2015年9月10日木曜日

MySQL 5.6で Assertion failure in thread

■現象
my.cnfにquery_cacheの設定を追記してmysqlを再起動したら起動に失敗
追記した部分↓(問題あり?)
query_cache_limit = 16M
query_cache_size = 512M
query_cache_type = 1
■エラーログ確認
○/var/mysql/logs/error.log
2015-09-08 20:02:41 7f9721e4e720  InnoDB: Assertion failure in thread 140287085438752 in file ut0mem.cc line 105
InnoDB: Failing assertion: ret || !assert_on_error
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.6/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
11:02:41 UTC - mysqld got signal 6 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed,
something is definitely wrong and this may fail.
key_buffer_size=8388608
read_buffer_size=131072
max_used_connections=0
max_threads=151
thread_count=0
connection_count=0
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 68241 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.
Thread pointer: 0x0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0 thread_stack 0x40000
/usr/local/mysql/bin/mysqld(my_print_stacktrace+0x35)[0x8e1b75]
/usr/local/mysql/bin/mysqld(handle_fatal_signal+0x41b)[0x650a1b]
/lib64/libpthread.so.0[0x37bd00f4a0]
/lib64/libc.so.6(gsignal+0x35)[0x37bcc32885]
/lib64/libc.so.6(abort+0x175)[0x37bcc34065]
/usr/local/mysql/bin/mysqld[0xa2b557]
/usr/local/mysql/bin/mysqld[0xaafb60]
/usr/local/mysql/bin/mysqld[0xaae7f6]
/usr/local/mysql/bin/mysqld[0xa4f0ee]
/usr/local/mysql/bin/mysqld[0xa5c9cf]
/usr/local/mysql/bin/mysqld[0xa09f6f]
/usr/local/mysql/bin/mysqld[0x95a7f7]
/usr/local/mysql/bin/mysqld(_Z24ha_initialize_handlertonP13st_plugin_int+0x48)[0x58d388]
/usr/local/mysql/bin/mysqld[0x6e1f86]
/usr/local/mysql/bin/mysqld(_Z11plugin_initPiPPci+0xb3e)[0x6e567e]
/usr/local/mysql/bin/mysqld[0x580905]
/usr/local/mysql/bin/mysqld(_Z11mysqld_mainiPPc+0x4d8)[0x585898]
/lib64/libc.so.6(__libc_start_main+0xfd)[0x37bcc1ecdd]
/usr/local/mysql/bin/mysqld[0x577bdd]
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.
crash(;゚Д゚)!?
エラーメッセージでググッてみると、「MySQLがクラッシュした」という記事ばかりで青くなりました。
不用意に再起動した自分を呪いつつ、設定ファイルを変えたタイミングだったわけでまずはそちらを確認。
結果、上述したmy.cnfの記述に問題があったようなのですが。
なにが悪かったのか良くわからず・・・query_cacheの記述が違うのかもしれません。
これについてはまたきちんと原因を調べるとして、起動までにやったことを残しておきます。
リカバリーはしなくて済みました。

■やったこと
○my.cnfの上記をコメントアウトして再起動
→下記エラーで起動せず
[root@dev init.d]# ./mysql.server start
Starting MySQL. ERROR! The server quit without updating PID file (/var/mysql/data/dev.xxxxxx-xxx.net.pid).
上記エラーをスタンダードな手順での解消を試みます。

○起動に失敗したときに残ってしまったプロセスを確認
[root@dev logs]# ps aux | grep mysql
root     24734  0.0  0.0 106152  1384 pts/0    S    20:02   0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock -
mysql    24805  0.0  0.1 261160 21736 pts/0    Sl   20:02   0:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --log-error=/var/et=/var/lib/mysql/mysql.sock
root     28203  0.0  0.0 107516   940 pts/0    S+   21:20   0:00 grep mysql

○mysqlが起動しているmysqldをkill
[root@dev logs]# kill 24805
[root@dev logs]# ps aux | grep mysql
root     28207  0.0  0.0 107516   944 pts/0    S+   21:20   0:00 grep mysql

○再起動前に念のためステータス確認するとロックファイルがあったのでそれをリネーム(削除でもいいと思います)
[root@dev logs]# /etc/rc.d/init.d/mysql.server status
 ERROR! MySQL is not running, but lock file (/var/lock/subsys/mysql) exists
[root@dev logs]# cd /var/lock/subsys
[root@dev subsys]# mv mysql _mysql

○再起動
[root@dev subsys]# /etc/rc.d/init.d/mysql.server start
Starting MySQL.. SUCCESS!

★教訓
稼働中のDBを不用意に設定変更・再起動しない
my.cnfをいじるときはかならず確実な情報をもとに編集・再起動
クラッシュを疑う前に胸に手をあてて自分の行動を鑑み、小さな部分から対応を潰していく

★Tips
mysql強制起動オプション(my.cnfに追記する)
innodb_force_recovery = 3
※1~6まで指定できて、1が一番やさしい強制。通常は1から順番に設定しながら起動確認していくようです。

0 件のコメント:

コメントを投稿

注: コメントを投稿できるのは、このブログのメンバーだけです。