Comment 5 for bug 1384568

Revision history for this message
Przemek (pmalkowski) wrote : Re: EXPLAIN crashes server

I can reproduce the crash using the test case on PS 5.6.19 and PS 5.6.21, however, when I install jemalloc, no more crashing happens. So seems that using jemalloc may be a good enough workaround for now.

[root@vagrant-centos65 ~]# rpm -qa|grep Percona-Server
Percona-Server-shared-56-5.6.21-rel70.1.el6.x86_64
Percona-Server-shared-51-5.1.73-rel14.12.624.rhel6.x86_64
Percona-Server-client-56-5.6.21-rel70.1.el6.x86_64
Percona-Server-server-56-5.6.21-rel70.1.el6.x86_64

MySQL> DROP DATABASE test;CREATE DATABASE test;USE test;CREATE TABLE t1(a INT KEY,b TEXT)ENGINE=InnoDB;explain extended select * FROM t1 x,t1 y where(x.a=2 or (x.a,x.b)in ((0,0),(5,0),(4,3))) and y.a=x.a and y.b=x.b;
Query OK, 1 row affected (0.15 sec)

Query OK, 1 row affected (0.00 sec)

Database changed
Query OK, 0 rows affected (0.35 sec)

ERROR 2013 (HY000): Lost connection to MySQL server during query

Err log:
2014-12-02 11:47:39 10633 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.6.21-70.1' socket: '/var/lib/mysql/mysql.sock' port: 3306 Percona Server (GPL), Release 70.1, Revision 698
11:51:19 UTC - 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.
Please help us make Percona Server better by reporting any
bugs at http://bugs.percona.com/

key_buffer_size=8388608
read_buffer_size=131072
max_used_connections=1
max_threads=153
thread_count=1
connection_count=1
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 69184 K bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x2c3dfa0
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 = 7fcac40dfd40 thread_stack 0x40000
/usr/sbin/mysqld(my_print_stacktrace+0x2c)[0x8bdcec]
/usr/sbin/mysqld(handle_fatal_signal+0x461)[0x6512a1]
/lib64/libpthread.so.0(+0xf710)[0x7fcae304b710]
/lib64/libc.so.6(+0x89b78)[0x7fcae16feb78]
/lib64/libc.so.6(memmove+0x192)[0x7fcae16f8992]
/usr/sbin/mysqld(_ZN6String4copyERKS_+0x26)[0x716126]
/usr/sbin/mysqld(_ZN20cmp_item_sort_string11store_valueEP4Item+0x33)[0x5cdb43]
/usr/sbin/mysqld(_ZN12cmp_item_row11store_valueEP4Item+0x7c)[0x5c91ac]
/usr/sbin/mysqld(_ZN12Item_func_in18fix_length_and_decEv+0x8b4)[0x5c9c24]
/usr/sbin/mysqld(_ZN9Item_func10fix_fieldsEP3THDPP4Item+0x1f5)[0x5e6d75]
/usr/sbin/mysqld(_ZN12Item_func_in10fix_fieldsEP3THDPP4Item+0x13)[0x5bfbd3]
/usr/sbin/mysqld(_ZN9Item_cond10fix_fieldsEP3THDPP4Item+0x106)[0x5bf576]
/usr/sbin/mysqld(_ZN9Item_cond10fix_fieldsEP3THDPP4Item+0x106)[0x5bf576]
/usr/sbin/mysqld(_Z11setup_condsP3THDP10TABLE_LISTS2_PP4Item+0x10a)[0x68a63a]
/usr/sbin/mysqld(_ZN4JOIN7prepareEP10TABLE_LISTjP4ItemjP8st_orderS5_S3_P13st_select_lexP18st_select_lex_unit+0x4de)[0x6ed4be]
/usr/sbin/mysqld(_Z12mysql_selectP3THDP10TABLE_LISTjR4ListI4ItemEPS4_P10SQL_I_ListI8st_orderESB_S7_yP13select_resultP18st_select_lex_unitP13st_select_lex+0x89e)[0x6f6a2e]
/usr/sbin/mysqld[0x7c572d]
/usr/sbin/mysqld(_Z24explain_query_expressionP3THDP13select_result+0x67)[0x7ca617]
/usr/sbin/mysqld[0x55ae37]
/usr/sbin/mysqld(_Z21mysql_execute_commandP3THD+0x378f)[0x6d288f]
/usr/sbin/mysqld(_Z11mysql_parseP3THDPcjP12Parser_state+0x5c8)[0x6d6168]
/usr/sbin/mysqld(_Z16dispatch_command19enum_server_commandP3THDPcj+0xfb7)[0x6d7887]
/usr/sbin/mysqld(_Z24do_handle_one_connectionP3THD+0x162)[0x6a57f2]
/usr/sbin/mysqld(handle_one_connection+0x40)[0x6a58e0]
/usr/sbin/mysqld(pfs_spawn_thread+0x143)[0xac8523]
/lib64/libpthread.so.0(+0x79d1)[0x7fcae30439d1]
/lib64/libc.so.6(clone+0x6d)[0x7fcae175d9dd]

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

[root@vagrant-centos65 ~]# yum install -y jemalloc.x86_64
[root@vagrant-centos65 ~]# /etc/init.d/mysql restart
Shutting down MySQL (Percona Server).. SUCCESS!
Starting MySQL (Percona Server)... SUCCESS!

[root@vagrant-centos65 ~]# lsof -p `pidof mysqld`|grep jema
mysqld 10907 mysql mem REG 8,1 210024 6961 /usr/lib64/libjemalloc.so.1

MySQL> DROP DATABASE test;CREATE DATABASE test;USE test;CREATE TABLE t1(a INT KEY,b TEXT)ENGINE=InnoDB;explain extended select * FROM t1 x,t1 y where(x.a=2 or (x.a,x.b)in ((0,0),(5,0),(4,3))) and y.a=x.a and y.b=x.b;
Query OK, 1 row affected (0.02 sec)

Query OK, 1 row affected (0.00 sec)

Database changed
Query OK, 0 rows affected (0.44 sec)

+----+-------------+-------+--------+---------------+---------+---------+----------+------+----------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+-------+--------+---------------+---------+---------+----------+------+----------+-------------+
| 1 | SIMPLE | x | ALL | PRIMARY | NULL | NULL | NULL | 1 | 100.00 | Using where |
| 1 | SIMPLE | y | eq_ref | PRIMARY | PRIMARY | 4 | test.x.a | 1 | 100.00 | Using where |
+----+-------------+-------+--------+---------------+---------+---------+----------+------+----------+-------------+
2 rows in set, 1 warning (0.00 sec)

With jemalloc, I cannot reproduce the crash even in a 100 loop of the test case.