MySQL 5.6 Seg Fault during Select [solved]

mysql

#1

Hi,

Private Build - Stack: Ubuntu, Node, MySql

Mysql installed with pre dependencies:

sudo apt-add-repository -y 'deb http://ppa.launchpad.net/ondrej/mysql-experimental/ubuntu precise main'
sudo apt-get update; sudo DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server-5.6

A recent change to a select statement in the code is causing the tests to fail at the same location everytime
circleCI runs. The tests pass normally on our local machines (5.6.27-0ubuntu0.14.04.1).

Error message received during tests: PROTOCOL_CONNECTION_LOST followed by PROTOCOL_ENQUEUE_AFTER_FATAL_ERROR errors.

I’ve sshed onto the circleCI machine to test what is causing the error and traced it to a single select statement.
Before the query is run:

ubuntu@box18:~$ mysqladmin version
mysqladmin  Ver 8.42 Distrib 5.6.14, for debian-linux-gnu on x86_64
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Server version		5.6.14-1+debphp.org~precise+1
Protocol version	10
Connection		Localhost via UNIX socket
UNIX socket		/var/run/mysqld/mysqld.sock
Uptime:			1 min 2 sec

Threads: 1  Questions: 113  Slow queries: 0  Opens: 836  Flush tables: 1  Open tables: 207  Queries per second avg: 1.822

After the query is run:

ubuntu@box18:~$ mysqladmin version
mysqladmin  Ver 8.42 Distrib 5.6.14, for debian-linux-gnu on x86_64
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Server version		5.6.14-1+debphp.org~precise+1
Protocol version	10
Connection		Localhost via UNIX socket
UNIX socket		/var/run/mysqld/mysqld.sock
Uptime:			3 sec

Threads: 1  Questions: 113  Slow queries: 0  Opens: 835  Flush tables: 1  Open tables: 207  Queries per second avg: 37.666

I believe that the uptime showing 3s points to mysqld crashing and restarting (http://dev.mysql.com/doc/refman/5.0/en/gone-away.html).

I ran mysqld from the command line, connected another ssh session, and ran the sql:

ubuntu@box401:/var/log$ sudo mysqld --verbose --log-error=/var/log/test.log
2016-01-26 15:09:19 0 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
2016-01-26 15:09:19 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-01-26 15:09:19 33315 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
2016-01-26 15:09:19 33315 [Note] Plugin 'FEDERATED' is disabled.
2016-01-26 15:09:19 33315 [Note] InnoDB: The InnoDB memory heap is disabled
2016-01-26 15:09:19 33315 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-01-26 15:09:19 33315 [Note] InnoDB: Compressed tables use zlib 1.2.3.4
2016-01-26 15:09:19 33315 [Note] InnoDB: Using Linux native AIO
2016-01-26 15:09:19 33315 [Note] InnoDB: Using CPU crc32 instructions
2016-01-26 15:09:19 33315 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2016-01-26 15:09:19 33315 [Note] InnoDB: Completed initialization of buffer pool
2016-01-26 15:09:19 33315 [Note] InnoDB: Highest supported file format is Barracuda.
2016-01-26 15:09:19 33315 [Note] InnoDB: 128 rollback segment(s) are active.
2016-01-26 15:09:19 33315 [Note] InnoDB: Waiting for purge to start
2016-01-26 15:09:19 33315 [Note] InnoDB: 5.6.14 started; log sequence number 15613304
2016-01-26 15:09:19 33315 [Note] Server hostname (bind-address): '127.0.0.1'; port: 3306
2016-01-26 15:09:19 33315 [Note]   - '127.0.0.1' resolves to '127.0.0.1';
2016-01-26 15:09:19 33315 [Note] Server socket created on IP: '127.0.0.1'.
2016-01-26 15:09:19 33315 [Note] Event Scheduler: Loaded 0 events
2016-01-26 15:09:19 33315 [Note] mysqld: ready for connections.
Version: '5.6.14-1+debphp.org~precise+1'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  (Ubuntu)
22:09:54 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.

key_buffer_size=16777216
read_buffer_size=131072
max_used_connections=1
max_threads=151
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 = 76425 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x7fd65f6074c0
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 = 7fd62e65ae70 thread_stack 0x30000
mysqld(my_print_stacktrace+0x29)[0x7fd65e21ccf9]
mysqld(handle_fatal_signal+0x3d6)[0x7fd65dfb4d36]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x10340)[0x7fd65cade340]
mysqld(_ZN9ha_myisam11ft_init_extEjjP6String+0x19)[0x7fd65e409179]
mysqld(_ZN15Item_func_match11init_searchEb+0x185)[0x7fd65df5e2f5]
mysqld(_ZN15Item_func_match11init_searchEb+0xc5)[0x7fd65df5e235]
mysqld(_ZN15Item_func_match11init_searchEb+0xc5)[0x7fd65df5e235]
mysqld(_Z12init_ftfuncsP3THDP13st_select_lexb+0x67)[0x7fd65dff0097]
mysqld(_ZN4JOIN8optimizeEv+0x2113)[0x7fd65e187fb3]
mysqld(_Z12mysql_selectP3THDP10TABLE_LISTjR4ListI4ItemEPS4_P10SQL_I_ListI8st_orderESB_S7_yP13select_resultP18st_select_lex_unitP13st_select_lex+0x22e)[0x7fd65e052a0e]
mysqld(_Z13handle_selectP3THDP13select_resultm+0x19f)[0x7fd65e05329f]
mysqld(+0x355cee)[0x7fd65decdcee]
mysqld(_Z21mysql_execute_commandP3THD+0x11de)[0x7fd65e030d8e]
mysqld(+0x4be448)[0x7fd65e036448]
mysqld(_Z16dispatch_command19enum_server_commandP3THDPcj+0x242c)[0x7fd65e038eec]
mysqld(_Z24do_handle_one_connectionP3THD+0x105)[0x7fd65e004c95]
mysqld(handle_one_connection+0x46)[0x7fd65e004dd6]
mysqld(pfs_spawn_thread+0x122)[0x7fd65e3f3f12]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x8182)[0x7fd65cad6182]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d)[0x7fd65c1ef47d]

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

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.

I’m really not sure where to go at this point.

Thanks for any help,
Dan


#2

I managed to refactor the select statement so that it worked. It used to be:

select results.* 
from (
awsome subselect
) as results
where full text index matches in boolean mode;

I changed it too:

select results.* 
from (
awsome subselect
where full text index matches in boolean mode
) as results;

The crash might have been from the arrangement of the query and/or in combination with the fact that one of the full text indexes was not created properly.

Thanks,
Dan


#3