Troubleshooting MySQL Database Crashes

crashinnodbMySQL

Our mysql instance is keep crashing after every 5-10 minutes very frequently. We have around 600 databases on that instance. I think 600 is not a big number of databases given the size of databases are not large.

I am pasting the portion of the log which comes up everytime mysql crashes:

Here is the log:

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.
150605 11:43:31 mysqld_safe Number of processes running now: 0
150605 11:43:31 mysqld_safe mysqld restarted
2015-06-05 11:43:32 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-06-05 11:43:32 18075 [Note] Plugin 'FEDERATED' is disabled.
2015-06-05 11:43:32 18075 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-06-05 11:43:32 18075 [Note] InnoDB: The InnoDB memory heap is disabled
2015-06-05 11:43:32 18075 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-06-05 11:43:32 18075 [Note] InnoDB: Memory barrier is not used
2015-06-05 11:43:32 18075 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-06-05 11:43:32 18075 [Note] InnoDB: Using Linux native AIO
2015-06-05 11:43:32 18075 [Note] InnoDB: Using CPU crc32 instructions
2015-06-05 11:43:32 18075 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-06-05 11:43:32 18075 [Note] InnoDB: Completed initialization of buffer pool
2015-06-05 11:43:32 18075 [Note] InnoDB: Highest supported file format is Barracuda.
2015-06-05 11:43:32 18075 [Note] InnoDB: Log scan progressed past the checkpoint lsn 49972171315
2015-06-05 11:43:32 18075 [Note] InnoDB: Database was not shutdown normally!
2015-06-05 11:43:32 18075 [Note] InnoDB: Starting crash recovery.
2015-06-05 11:43:32 18075 [Note] InnoDB: Reading tablespace information from the .ibd files...
2015-06-05 11:44:00 18075 [Note] InnoDB: Restoring possible half-written data pages
2015-06-05 11:44:00 18075 [Note] InnoDB: from the doublewrite buffer...
InnoDB: Doing recovery: scanned up to log sequence number 49972236423
2015-06-05 11:44:00 18075 [Note] InnoDB: Starting an apply batch of log records to the database...
InnoDB: Progress in percent: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
InnoDB: Apply batch completed
InnoDB: Last MySQL binlog file position 0 11810416, file name replication.000396
2015-06-05 11:44:02 18075 [Note] InnoDB: 128 rollback segment(s) are active.
2015-06-05 11:44:02 18075 [Note] InnoDB: Waiting for purge to start
2015-06-05 11:44:02 18075 [Note] InnoDB: 5.6.20 started; log sequence number 49972236423
2015-06-05 11:44:02 18075 [Note] Server hostname (bind-address): '*'; port: 3306
2015-06-05 11:44:02 18075 [Note] IPv6 is available.
2015-06-05 11:44:02 18075 [Note]   - '::' resolves to '::';
2015-06-05 11:44:02 18075 [Note] Server socket created on IP: '::'.
2015-06-05 11:44:02 18075 [Warning] 'user' entry 'root@node1a' ignored in --skip-name-resolve mode.
2015-06-05 11:44:02 18075 [Warning] 'user' entry '@node1a' ignored in --skip-name-resolve mode.
2015-06-05 11:44:02 18075 [Warning] 'proxies_priv' entry '@ root@node1a' ignored in --skip-name-resolve mode.
2015-06-05 11:44:02 18075 [Note] Event Scheduler: Loaded 0 events
2015-06-05 11:44:02 18075 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.6.20-log'  socket: '/data/mysql/mysql.sock'  port: 3306  MySQL Community Server (GPL)
2015-06-05 11:46:03 18075 [Warning] InnoDB: Cannot open table csp716/unlock from the internal data dictionary of InnoDB though the .frm file for the table exists. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html for how you can resolve the problem.
pure virtual method called
terminate called without an active exception
15:46: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=281
max_threads=10000
thread_count=281
connection_count=281
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 3985223 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x10d458b0
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 = 7fa2cb6dae18 thread_stack 0x40000
/usr/sbin/mysqld(my_print_stacktrace+0x35)[0x8d9d85]
/usr/sbin/mysqld(handle_fatal_signal+0x494)[0x665344]
/lib64/libpthread.so.0(+0xf710)[0x7fa6cbd26710]
/lib64/libc.so.6(gsignal+0x35)[0x7fa6ca9d1635]
/lib64/libc.so.6(abort+0x175)[0x7fa6ca9d2e15]
/usr/lib64/libstdc++.so.6(_ZN9__gnu_cxx27__verbose_terminate_handlerEv+0x12d)[0x7fa6cb28ba5d]
/usr/lib64/libstdc++.so.6(+0xbcbe6)[0x7fa6cb289be6]
/usr/lib64/libstdc++.so.6(+0xbcc13)[0x7fa6cb289c13]
/usr/lib64/libstdc++.so.6(+0xbd53f)[0x7fa6cb28a53f]
/usr/sbin/mysqld(_ZN15Item_bool_func220convert_constant_argEP3THDP4ItemPS3_+0x40)[0x5dc2d0]
/usr/sbin/mysqld(_ZN15Item_bool_func218fix_length_and_decEv+0xe3)[0x5dccd3]
/usr/sbin/mysqld(_ZN9Item_func10fix_fieldsEP3THDPP4Item+0x25d)[0x5ff81d]
/usr/sbin/mysqld(_ZN9Item_cond10fix_fieldsEP3THDPP4Item+0x153)[0x5d2c33]
/usr/sbin/mysqld(_Z11setup_condsP3THDP10TABLE_LISTS2_PP4Item+0x130)[0x6980c0]
/usr/sbin/mysqld(_ZN4JOIN7prepareEP10TABLE_LISTjP4ItemjP8st_orderS5_S3_P13st_select_lexP18st_select_lex_unit+0x4ea)[0x6fc67a]
/usr/sbin/mysqld(_Z12mysql_selectP3THDP10TABLE_LISTjR4ListI4ItemEPS4_P10SQL_I_ListI8st_orderESB_S7_yP13select_resultP18st_select_lex_unitP13st_select_lex+0x890)[0x704a60]
/usr/sbin/mysqld(_Z13handle_selectP3THDP13select_resultm+0x1a7)[0x704cc7]
/usr/sbin/mysqld[0x6df10d]
/usr/sbin/mysqld(_Z21mysql_execute_commandP3THD+0x157f)[0x6e1adf]
/usr/sbin/mysqld(_ZN13sp_instr_stmt9exec_coreEP3THDPj+0xa2)[0x8148d2]
/usr/sbin/mysqld(_ZN12sp_lex_instr23reset_lex_and_exec_coreEP3THDPjb+0x228)[0x814c18]
/usr/sbin/mysqld(_ZN12sp_lex_instr29validate_lex_and_execute_coreEP3THDPjb+0x8f)[0x816acf]
/usr/sbin/mysqld(_ZN13sp_instr_stmt7executeEP3THDPj+0x1b0)[0x8171b0]
/usr/sbin/mysqld(_ZN7sp_head7executeEP3THDb+0x782)[0x66bd22]
/usr/sbin/mysqld(_ZN7sp_head17execute_procedureEP3THDP4ListI4ItemE+0x6d7)[0x66d217]
/usr/sbin/mysqld(_Z21mysql_execute_commandP3THD+0x11ba)[0x6e171a]
/usr/sbin/mysqld(_Z11mysql_parseP3THDPcjP12Parser_state+0x3b8)[0x6e5658]
/usr/sbin/mysqld(_Z16dispatch_command19enum_server_commandP3THDPcj+0x14ba)[0x6e6bca]
/usr/sbin/mysqld(_Z24do_handle_one_connectionP3THD+0xcf)[0x6b377f]
/usr/sbin/mysqld(handle_one_connection+0x47)[0x6b38a7]
/usr/sbin/mysqld(pfs_spawn_thread+0x12a)[0xafde1a]
/lib64/libpthread.so.0(+0x79d1)[0x7fa6cbd1e9d1]
/lib64/libc.so.6(clone+0x6d)[0x7fa6caa8786d]

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (7fa23486c6c0): is an invalid pointer
Connection ID (thread ID): 303
Status: NOT_KILLED

Best Answer

The answer is in the log itself

2015-06-05 11:44:02 18075 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.6.20-log'  socket: '/data/mysql/mysql.sock'  port: 3306  MySQL Community Server (GPL)

MySQL had finished starting up at 2015-06-05 11:44:02

Look at the error message 2 minutes later

2015-06-05 11:46:03 18075 [Warning] InnoDB: Cannot open table csp716/unlock from the internal data dictionary of InnoDB though the .frm file for the table exists. See http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting.html for how you can resolve the problem.

That line says

Cannot open table csp716/unlock from the internal data dictionary of InnoDB though the .frm file for the table exists

In the database csp716 you have a table called unlock. Its data dictionary entry (located inside ibdata1) is broken. Look at the stack trace, it appears you were doing some SELECT with a JOIN. One of the tables was csp716.unlock. Every time you attempt to access that table, mysqld crashes.

You many need to drop the table and restore it from a backup.

You could also try to reattach the tablespace_id entry in ibdata1 back to the table itself.

See these posts on how to address this