Bug #74490 Assertion `table->key_read == 0' failed | sig 6 in close_open_tables
Submitted: 22 Oct 2014 2:08 Modified: 22 Oct 2014 6:51
Reporter: Ramesh Sivaraman Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version:5.6.20-debug, 5.6.22 OS:Linux (CentOS 7)
Assigned to: CPU Architecture:Any

[22 Oct 2014 2:08] Ramesh Sivaraman
Description:
mysqld: /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_base.cc:1479: void close_thread_table(THD*, TABLE**): Assertion `table->key_read == 0' failed.
16:19:40 UTC - mysqld got signal 6 ;

**** GDB info

#0  0x00007f45ff948771 in pthread_kill () from /lib64/libpthread.so.0
#1  0x0000000000a9035e in my_write_core (sig=6) at /ssd/ramesh/mysql-server/mysql-5.6/mysys/stacktrace.c:422
#2  0x0000000000723688 in handle_fatal_signal (sig=6) at /ssd/ramesh/mysql-server/mysql-5.6/sql/signal_handler.cc:230
#3  <signal handler called>
#4  0x00007f45fe7545c9 in raise () from /lib64/libc.so.6
#5  0x00007f45fe755cd8 in abort () from /lib64/libc.so.6
#6  0x00007f45fe74d536 in __assert_fail_base () from /lib64/libc.so.6
#7  0x00007f45fe74d5e2 in __assert_fail () from /lib64/libc.so.6
#8  0x000000000076088c in close_thread_table (thd=0x7f456c724000, table_ptr=0x7f456c7240b0) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_base.cc:1479
#9  0x000000000076029f in close_open_tables (thd=0x7f456c724000) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_base.cc:1241
#10 0x0000000000760806 in close_thread_tables (thd=0x7f456c724000) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_base.cc:1467
#11 0x00000000007d61b8 in mysql_execute_command (thd=0x7f456c724000) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_parse.cc:5014
#12 0x00000000007d8fa4 in mysql_parse (thd=0x7f456c724000, rawbuf=0x7f456281f010 "EXPLAIN EXTENDED SELECT * FROM t1 UNION SELECT * FROM t1 ORDER BY(SELECT a FROM t2 WHERE b=12)", length=94, parser_state=0x7f45fff3fe70) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_parse.cc:6245
#13 0x00000000007cc557 in dispatch_command (command=COM_QUERY, thd=0x7f456c724000, packet=0x7f456c762001 "", packet_length=94) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_parse.cc:1332
#14 0x00000000007cb646 in do_command (thd=0x7f456c724000) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_parse.cc:1034
#15 0x0000000000793a61 in do_handle_one_connection (thd_arg=0x7f456c724000) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_connect.cc:982
#16 0x000000000079354a in handle_one_connection (arg=0x7f456c724000) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_connect.cc:898
#17 0x0000000000ad4b5c in pfs_spawn_thread (arg=0x7f45f9338b00) at /ssd/ramesh/mysql-server/mysql-5.6/storage/perfschema/pfs.cc:1860
#18 0x00007f45ff943df3 in start_thread () from /lib64/libpthread.so.0
#19 0x00007f45fe81501d in clone () from /lib64/libc.so.6

How to repeat:
create table t1(c1 INT);
CREATE TABLE t2(a int KEY,b int,c int,KEY(b)) ENGINE=INNODB;
EXPLAIN EXTENDED SELECT * FROM t1 UNION SELECT * FROM t1 ORDER BY(SELECT a FROM t2 WHERE b=12);
[22 Oct 2014 6:51] MySQL Verification Team
Hello Ramesh Sivaraman,

Thank you for the bug report and test case.

Thanks,
Umesh
[22 Oct 2014 6:52] MySQL Verification Team
// 5.6.22 only debug build affected

mysql> show variables like '%version%';
+-------------------------+---------------------------------------------------------+
| Variable_name           | Value                                                   |
+-------------------------+---------------------------------------------------------+
| innodb_version          | 5.6.22                                                  |
| protocol_version        | 10                                                      |
| slave_type_conversions  |                                                         |
| version                 | 5.6.22-enterprise-commercial-advanced                   |
| version_comment         | MySQL Enterprise Server - Advanced Edition (Commercial) |
| version_compile_machine | x86_64                                                  |
| version_compile_os      | Linux                                                   |
+-------------------------+---------------------------------------------------------+
7 rows in set (0.00 sec)

mysql> create table t1(c1 INT);
Query OK, 0 rows affected (0.03 sec)

mysql> CREATE TABLE t2(a int KEY,b int,c int,KEY(b)) ENGINE=INNODB;
Query OK, 0 rows affected (0.02 sec)

mysql> EXPLAIN EXTENDED SELECT * FROM t1 UNION SELECT * FROM t1 ORDER BY(SELECT a FROM t2 WHERE b=12);
+----+--------------+------------+------+---------------+------+---------+-------+------+----------+---------------------------------+
| id | select_type  | table      | type | possible_keys | key  | key_len | ref   | rows | filtered | Extra                           |
+----+--------------+------------+------+---------------+------+---------+-------+------+----------+---------------------------------+
|  1 | PRIMARY      | t1         | ALL  | NULL          | NULL | NULL    | NULL  |    1 |   100.00 | NULL                            |
|  2 | UNION        | t1         | ALL  | NULL          | NULL | NULL    | NULL  |    1 |   100.00 | NULL                            |
|  3 | SUBQUERY     | t2         | ref  | b             | b    | 5       | const |    1 |   100.00 | Using index                     |
| NULL | UNION RESULT | <union1,2> | ALL  | NULL          | NULL | NULL    | NULL  | NULL |     NULL | Using temporary; Using filesort |
+----+--------------+------------+------+---------------+------+---------+-------+------+----------+---------------------------------+
4 rows in set, 1 warning (0.00 sec)

// Debug build

(gdb) bt
#0  0x0000003bf260c8ac in pthread_kill () from /lib64/libpthread.so.0
#1  0x0000000000afe982 in my_write_core (sig=6) at /export/home/pb2/build/sb_0-13146752-1409933888.09/mysqlcom-pro-5.6.22/mysys/stacktrace.c:422
#2  0x000000000077e6cc in handle_fatal_signal (sig=6) at /export/home/pb2/build/sb_0-13146752-1409933888.09/mysqlcom-pro-5.6.22/sql/signal_handler.cc:230
#3  <signal handler called>
#4  0x0000003bf2232635 in raise () from /lib64/libc.so.6
#5  0x0000003bf2233e15 in abort () from /lib64/libc.so.6
#6  0x0000003bf222b75e in __assert_fail_base () from /lib64/libc.so.6
#7  0x0000003bf222b820 in __assert_fail () from /lib64/libc.so.6
#8  0x00000000007bceee in close_thread_table (thd=0x8c99440, table_ptr=0x8c994f0) at /export/home/pb2/build/sb_0-13146752-1409933888.09/mysqlcom-pro-5.6.22/sql/sql_base.cc:1479
#9  0x00000000007bc8f5 in close_open_tables (thd=0x8c99440) at /export/home/pb2/build/sb_0-13146752-1409933888.09/mysqlcom-pro-5.6.22/sql/sql_base.cc:1241
#10 0x00000000007bce72 in close_thread_tables (thd=0x8c99440) at /export/home/pb2/build/sb_0-13146752-1409933888.09/mysqlcom-pro-5.6.22/sql/sql_base.cc:1467
#11 0x000000000083489c in mysql_execute_command (thd=0x8c99440) at /export/home/pb2/build/sb_0-13146752-1409933888.09/mysqlcom-pro-5.6.22/sql/sql_parse.cc:5014
#12 0x00000000008375d1 in mysql_parse (thd=0x8c99440, rawbuf=0x7fcd9c004fd0 "EXPLAIN EXTENDED SELECT * FROM t1 UNION SELECT * FROM t1 ORDER BY(SELECT a FROM t2 WHERE b=12)", length=94,
    parser_state=0x7fcdbeb29680) at /export/home/pb2/build/sb_0-13146752-1409933888.09/mysqlcom-pro-5.6.22/sql/sql_parse.cc:6245
#13 0x000000000082a3a2 in dispatch_command (command=COM_QUERY, thd=0x8c99440, packet=0x8dc7c91 "", packet_length=94)
    at /export/home/pb2/build/sb_0-13146752-1409933888.09/mysqlcom-pro-5.6.22/sql/sql_parse.cc:1332
#14 0x0000000000829407 in do_command (thd=0x8c99440) at /export/home/pb2/build/sb_0-13146752-1409933888.09/mysqlcom-pro-5.6.22/sql/sql_parse.cc:1034
#15 0x00000000007f0887 in do_handle_one_connection (thd_arg=0x8c99440) at /export/home/pb2/build/sb_0-13146752-1409933888.09/mysqlcom-pro-5.6.22/sql/sql_connect.cc:982
#16 0x00000000007f0358 in handle_one_connection (arg=0x8c99440) at /export/home/pb2/build/sb_0-13146752-1409933888.09/mysqlcom-pro-5.6.22/sql/sql_connect.cc:898
#17 0x0000000000e5c19d in pfs_spawn_thread (arg=0x8da98d0) at /export/home/pb2/build/sb_0-13146752-1409933888.09/mysqlcom-pro-5.6.22/storage/perfschema/pfs.cc:1860
#18 0x0000003bf26079d1 in start_thread () from /lib64/libpthread.so.0
#19 0x0000003bf22e886d in clone () from /lib64/libc.so.6