MySQLのエラーってこんなやつ DBIx::Sunny connect('database=isucon2;host=127.0.0.1;port=3306',' isucon2app',...) failed: Can't connect to MySQL server on '127.0. 0.1' (111) at /home/yoku0825/git/isucon2/webapp/perl/lib/Isucon2. pm line 29. 14/83
余談 “ER_LOCK_DEADLOCK”, 1213, “Deadlock found when trying to get lock; try restarting transaction” 「デッドロックした」んじゃなくて、「デッドロックになり そうな気配がしたのでロールバックした」という意味のネガ ティブメッセージ bugs.mysql.comとかで「デッドロック」というと「本当に デッドロックしてタイムアウトするまで身動きが取れなく なってるやつ」のこと 18/83
2000番台エラーの特徴 サーバーから切られた以外の理由の場合、OSエラーコード が載っていることが多い 例えばLinuxなら #define ENOENT 2 /* No such file or directory */ #define ENOSPC 28 /* No space left on device */ #define ETIMEDOUT 110 /* Connection timed out */ #define ECONNREFUSED 111 /* Connection refused */ #define EHOSTUNREACH 113 /* No route to host */ 26/83
2002: CR_CONNECTION_ERROR ERROR 2002 (HY000): Can't connect to local MySQL server through s ocket '/tmp/mysql.sock' (2) $ perror 2 OS error code 2: No such file or directory MySQL error code MY-000002: Error reading file '%s' (OS errno %d - %s) 27/83
2003: CR_CONN_HOST_ERROR $ mysql -h10.0.0.1 ERROR 2003 (HY000): Can't connect to MySQL server on '10.0.0.1' (110) $ perror 2003 110 Illegal error code: 2003 OS error code 110: Connection timed out 29/83
同じ2003のタイムアウトでもどっちがタイムアウトさせ るかによって違ったり mysql_options(mysql, MYSQL_OPT_READ_TIMEOUT, 1); mysql_real_connect(mysql); 2003: Can't connect to MySQL server on '192.168.225.201' (4) $ perror 4 OS error code 4: Interrupted system call 30/83
2000番台でもサーバーの都合も含むもの サーバー側のアイドルタイマー(wait_timeout)に引っか かってサーバー側から一方的にコネクションを切断されたり KILLステートメントで切断されたり mysql80 11> SELECT NOW(); ERROR 2006 (HY000): MySQL server has gone away mysql80 13> SELECT NOW(); ERROR 2013 (HY000): Lost connection to MySQL server during query 31/83
どこで切断されるかでエラー番号が変わる mysql80 11> SELECT NOW(); ERROR 2006 (HY000): MySQL server has gone away mysql80 13> SELECT NOW(); ERROR 2013 (HY000): Lost connection to MySQL server during query 33/83
2000番台でもサーバーの都合も含むもの MySQL 8.0でみんなよくググるコレ ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/mysql/5.6.41/lib/plugin/caching_sha2_pass word.so: cannot open shared object file: No such file or director y 34/83
実はもう1種類ある クライアントから送られてきたクライアントケーパビリ ティーで「要求する認証プラグインにクライアントが対応し ていないことがわかっちゃった」のでサーバーから接続を拒 否。 ERROR 1251 (08004): Client does not support authentication protoc ol requested by server; consider upgrading MySQL client 36/83
どこで認証に失敗するかでエラー番号が変わる ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/mysql/5.6.41/lib/plugin/caching_sha2_pass word.so: cannot open shared object file: No such file or director y ERROR 1251 (08004): Client does not support authentication protoc ol requested by server; consider upgrading MySQL client 38/83
たとえば エラーコード1251 SQLステート08004 エラーメッセージが “Client does not ..” ERROR 1251 (08004): Client does not support authentication protoc ol requested by server; consider upgrading MySQL client 46/83
perrorコマンド 内部理解のために役に立つのは、 どこまでが決め打ちメッ セージなのか がわかるフォーマットを見られること たとえば 1593: ER_BINLOG_FATAL_ERROR は(5.7の場 合) Slave I/O: The slave I/O thread stops because master and slave ha ve equal MySQL server ids; these ids must be different for replic ation to work (or the --replicate-same-server-id option must be u sed on slave but this does not always make sense; please check th e manual before using it), Error_code: 1593 Slave I/O: The slave I/O thread stops because SET @master_heartbe at_period on master failed. Error: , Error_code: 1593 Slave SQL: Fatal error: Failed to initialize the master info stru cture, Error_code: 1593 52/83
stdoutとstderrが繋がっているだけなので おもむろにエラーログの書式をガン無視したInnoDBのログ に遭遇したことってありません? タイムスタンプとかログレベルとか一切ないやつ ‐ 180731 13:29:08 [Note] InnoDB: 5.5.61 started; log sequence numbe r 1625977 InnoDB: Error: page 1234 log sequence number InnoDB: is in the future! Current system log sequence number 1625 977 InnoDB: Your database may be corrupt or you may have copied the I nnoDB InnoDB: tablespace but not the InnoDB log files. See" InnoDB: https://dev.mysql.com/../forcing-innodb-recovery.html InnoDB: for more information. 66/83
有名なアレ mysqld got signal 11; 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=67108864 read_buffer_size=2093056 max_used_connections=0 max_connections=3000 threads_connected=0 It is possible that mysqld could use up to key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = 30773 512 K bytes of memory Hope that's ok; if not, decrease some variables in the equation. 75/83
実はこのメッセージはハードコード 115 my_safe_printf_stderr("%s", 116 "This could be because you hit a bug. It is also " 117 "possible that this binary\n" 118 "or one of the libraries it was linke d against is " 119 "corrupt, improperly built,\n" 120 "or misconfigured. This error can als o be caused by " 121 "malfunctioning hardware.\n"); sql/signal_handler.cc 76/83