Bug #84755 handle_fatal_signal (sig=11) in TABLE::set_keyread
Submitted: 31 Jan 2017 19:49 Modified: 19 Feb 2017 21:27
Reporter: Roel Van de Paar Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Server: Information schema Severity:S6 (Debug Builds)
Version:5.7.16, 5.7.17 OS:Any
Assigned to: CPU Architecture:Any

[31 Jan 2017 19:49] Roel Van de Paar
Description:
2017-01-31T19:27:44.819602Z 0 [Note] /sda/MS151116-mysql-5.7.16-linux-x86_64-debug/bin/mysqld: ready for connections.
Version: '5.7.16-debug'  socket: '/sda/MS151116-mysql-5.7.16-linux-x86_64-debug/socket.sock'  port: 19199  MySQL Community Server (GPL)
19:27:50 UTC - mysqld got signal 11 ;

Core was generated by `/sda/MS151116-mysql-5.7.16-linux-x86_64-debug/bin/mysqld --no-defaults --core-f'.
Program terminated with signal 11, Segmentation fault.
#0  0x00007fb5310a2741 in __pthread_kill (threadid=<optimized out>, signo=11) at ../nptl/sysdeps/unix/sysv/linux/pthread_kill.c:61
61        val = INTERNAL_SYSCALL (tgkill, err, 3, THREAD_GETMEM (THREAD_SELF, pid),
(gdb) bt
#0  0x00007fb5310a2741 in __pthread_kill (threadid=<optimized out>, signo=11) at ../nptl/sysdeps/unix/sysv/linux/pthread_kill.c:61
#1  0x0000000001822fb0 in my_write_core (sig=11) at /git/mysql-server_dbg/mysys/stacktrace.c:247
#2  0x0000000000e7457c in handle_fatal_signal (sig=11) at /git/mysql-server_dbg/sql/signal_handler.cc:220
#3  <signal handler called>
#4  0x000000000141f43a in TABLE::set_keyread (this=0x7fb505495030, flag=false) at /git/mysql-server_dbg/sql/table.h:1340
#5  0x000000000141ded8 in end_read_record (info=0x7fb505494ab0) at /git/mysql-server_dbg/sql/records.cc:360
#6  0x00000000015481f7 in QEP_TAB::cleanup (this=0x7fb505494a60) at /git/mysql-server_dbg/sql/sql_select.cc:2384
#7  0x0000000001543e05 in JOIN::destroy (this=0x7fb505494378) at /git/mysql-server_dbg/sql/sql_select.cc:938
#8  0x00000000015a3985 in st_select_lex::cleanup (this=0x7fb50542b0b0, full=true) at /git/mysql-server_dbg/sql/sql_union.cc:1061
#9  0x00000000015a34e0 in st_select_lex_unit::cleanup (this=0x7fb50542b390, full=true) at /git/mysql-server_dbg/sql/sql_union.cc:906
#10 0x00000000014f81d3 in mysql_execute_command (thd=0x7fb505419000, first_level=true) at /git/mysql-server_dbg/sql/sql_parse.cc:5002
#11 0x00000000014f97d5 in mysql_parse (thd=0x7fb505419000, parser_state=0x7fb531694560) at /git/mysql-server_dbg/sql/sql_parse.cc:5559
#12 0x00000000014eef69 in dispatch_command (thd=0x7fb505419000, com_data=0x7fb531694cb0, command=COM_QUERY) at /git/mysql-server_dbg/sql/sql_parse.cc:1427
#13 0x00000000014ede33 in do_command (thd=0x7fb505419000) at /git/mysql-server_dbg/sql/sql_parse.cc:995
#14 0x000000000161d370 in handle_connection (arg=0x7fb515be9840) at /git/mysql-server_dbg/sql/conn_handler/connection_handler_per_thread.cc:300
#15 0x000000000184f79c in pfs_spawn_thread (arg=0x7fb515a76120) at /git/mysql-server_dbg/storage/perfschema/pfs.cc:2188
#16 0x00007fb53109ddc5 in start_thread (arg=0x7fb531695700) at pthread_create.c:308
#17 0x00007fb52f4f873d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113

How to repeat:
DROP DATABASE test;
INSTALL PLUGIN auth_pam SONAME 'auth_pam.so';
INSTALL PLUGIN auth_pam_compat SONAME 'auth_pam_compat.so';
INSTALL PLUGIN InnoDB_locks SONAME 'ha_InnoDB.so';
SET @@global.debug='+d,use_attachable_trx';
SELECT table_schema,count(*)FROM information_schema.TABLES;
[31 Jan 2017 19:51] Roel Van de Paar
This may be a new regression (TBV)
[1 Feb 2017 6:25] MySQL Verification Team
Hello Roel,

Thank you for the report.
Observed that 5.7.17 debug build is affected.

Thanks,
Umesh
[1 Feb 2017 6:27] MySQL Verification Team
-- 5.6.35 debug build not affected with the provided test case
[6 Feb 2017 13:41] Erlend Dahl
Posted by developer:
 
5.7.9 GA displays the same behaviour. Though I question the wisdom of triggering debug sync points and then complain about asserts.

Btw the INSTALL PLUGINs are bogus, they are unrelated to the 'problem'.
[6 Feb 2017 22:27] Roel Van de Paar
Confirmed that the minimum testcase is;

SET @@global.debug='+d,use_attachable_trx';
SELECT * FROM INFORMATION_SCHEMA.TABLES;

I am not complaining, I am reporting. Feel free to close if the report is invalid.

As for using use_attachable_trx;
1) So does MTR 
   mysql-test/suite/innodb/t/attachable_trx.test
2) This is a part of the testcase in #1:

SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
START TRANSACTION;
SET @@global.debug = '+d,use_attachable_trx';
SELECT * FROM t1;   <<<<<<<<

This testcase;

SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
START TRANSACTION;
SET @@global.debug='+d,use_attachable_trx';
SELECT * FROM INFORMATION_SCHEMA.TABLES;   <<<<<<<<

Crashes the server all the same as above. So, it is a situation not covered in MTR.

3) This does not crash;

CREATE TABLE t1 (id int);  # does not matter if this is inside the trx or not
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
START TRANSACTION;
SET @@global.debug = '+d,use_attachable_trx';
SELECT * FROM t1; 

4) The crash is in cost model (introduced in 5.7) and 5.6.35 does not crash on the testcase (it provides the results requested).

My preliminary conclusion is;
1) The testcase could be expanded
2) There is a regression in the use_attachable_trx testcode in that it does not cater for the cost model
3) The cost model does not accommodate for use_attachable_trx when an I_S table is involved
4) The cost model does accommodate for use_attachable_trx when a normal table is involved

TLDR; The issue may not or may be significant, but there does seem to be a quality shortcoming
[6 Feb 2017 22:27] Roel Van de Paar
.
[8 Feb 2017 13:10] Erlend Dahl
Your testcase sets a debug flag. These flags are used within the server to simulate an internal failure or to force a certain behaviour. This is not possible for normal users of the production version.

Their use is in carefully crafted testcases that take these intended behaviour changes into account. Used in another context, there is no guarantee they will work at all, and no point in trying to make them do so.

Such flags are in our opinion not suitable for randomized testing, and the fact that they create asserts or crashes can't be used to draw conclusions about regressions or quality of the server.

In our opinion, you should remove the use of debug flags from your scripts.
[19 Feb 2017 21:27] Roel Van de Paar
I've removed the debug code from testing SQL. It's a bit with mixed feelings as we did find product shortcoming this way, but I also appreciate that the eventual ROI is not significant enough (unless substantial changes in the whole industry happen - i.e. more focus on perfect quality in favor of new features).