Bug #74740 Assertion `(*tables)->reginfo.lock_type >= TL_READ' failed in lock_external
Submitted: 7 Nov 2014 18:10 Modified: 10 Jul 2015 15:44
Reporter: Ramesh Sivaraman Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:5.6.20-debug, 5.6.22, 5.7.6 OS:Linux (CentOS 7)
Assigned to: CPU Architecture:Any

[7 Nov 2014 18:10] Ramesh Sivaraman
Description:
mysqld: /ssd/ramesh/mysql-server/mysql-5.6/sql/lock.cc:355: int lock_external(THD*, TABLE**, uint): Assertion `(*tables)->reginfo.lock_type >= TL_READ' failed.
18:06:16 UTC - mysqld got signal 6 ;

*** GDB info

#0  0x00007f9a2f547771 in pthread_kill () from /lib64/libpthread.so.0
#1  0x0000000000a954ea in my_write_core (sig=6) at /ssd/ramesh/mysql-server/mysql-5.6/mysys/stacktrace.c:422
#2  0x0000000000726494 in handle_fatal_signal (sig=6) at /ssd/ramesh/mysql-server/mysql-5.6/sql/signal_handler.cc:230
#3  <signal handler called>
#4  0x00007f9a2e3535c9 in raise () from /lib64/libc.so.6
#5  0x00007f9a2e354cd8 in abort () from /lib64/libc.so.6
#6  0x00007f9a2e34c536 in __assert_fail_base () from /lib64/libc.so.6
#7  0x00007f9a2e34c5e2 in __assert_fail () from /lib64/libc.so.6
#8  0x000000000093753e in lock_external (thd=0x7f999c35d000, tables=0x7f998ac12198, count=3) at /ssd/ramesh/mysql-server/mysql-5.6/sql/lock.cc:355
#9  0x00000000009372ee in mysql_lock_tables (thd=0x7f999c35d000, tables=0x7f998ad8aee8, count=3, flags=0) at /ssd/ramesh/mysql-server/mysql-5.6/sql/lock.cc:307
#10 0x000000000076b76f in lock_tables (thd=0x7f999c35d000, tables=0x7f998ac1f110, count=3, flags=0) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_base.cc:5949
#11 0x00000000007b1adf in mysql_insert (thd=0x7f999c35d000, table_list=0x7f998ac1f110, fields=..., values_list=..., update_fields=..., update_values=..., duplic=DUP_ERROR, ignore=false) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_insert.cc:909
#12 0x00000000007d43b7 in mysql_execute_command (thd=0x7f999c35d000) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_parse.cc:3443
#13 0x00000000007dbdbc in mysql_parse (thd=0x7f999c35d000, rawbuf=0x7f998ac1f010 "INSERT INTO t1 VALUES(1,1),(2,2),(3,1)", length=38, parser_state=0x7f9a2fafce70) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_parse.cc:6245
#14 0x00000000007cf36f in dispatch_command (command=COM_QUERY, thd=0x7f999c35d000, packet=0x7f9990e66001 "INSERT INTO t1 VALUES(1,1),(2,2),(3,1)", packet_length=38) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_parse.cc:1332
#15 0x00000000007ce45e in do_command (thd=0x7f999c35d000) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_parse.cc:1034
#16 0x0000000000796879 in do_handle_one_connection (thd_arg=0x7f999c35d000) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_connect.cc:982
#17 0x0000000000796362 in handle_one_connection (arg=0x7f999c35d000) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_connect.cc:898
#18 0x0000000000d71288 in pfs_spawn_thread (arg=0x7f9a2bbfea60) at /ssd/ramesh/mysql-server/mysql-5.6/storage/perfschema/pfs.cc:1860
#19 0x00007f9a2f542df3 in start_thread () from /lib64/libpthread.so.0
#20 0x00007f9a2e41401d in clone () from /lib64/libc.so.6

How to repeat:
DROP DATABASE test;CREATE DATABASE test;USE test;
create table t1(a CHAR (1)character set latin2,b varchar(1));
create procedure p1()create view v1 as select * from t1;
CREATE VIEW v1 AS SELECT a,(a + 1)AS y FROM t1;
create trigger ai after insert on t1 for each row call p1(new.a);
INSERT INTO t1 VALUES(1,1),(2,2),(3,1);
[7 Nov 2014 18:53] MySQL Verification Team
Hello Ramesh Sivaraman,

Thank you for the bug report and test case.
Confirmed with 5.6.22 that only debug build is affected.

Thanks,
Umesh
[7 Nov 2014 18:53] MySQL Verification Team
// 5.6.22 debug build

(gdb) bt
#0  0x0000003deb00c8ac in pthread_kill () from /lib64/libpthread.so.0
#1  0x0000000000b0011b in my_write_core (sig=6) at /pb2/build/sb_0-13562263-1414689457.82/mysqlcom-pro-5.6.22/mysys/stacktrace.c:422
#2  0x000000000077ecb8 in handle_fatal_signal (sig=6) at /pb2/build/sb_0-13562263-1414689457.82/mysqlcom-pro-5.6.22/sql/signal_handler.cc:230
#3  <signal handler called>
#4  0x0000003deac32625 in raise () from /lib64/libc.so.6
#5  0x0000003deac33e05 in abort () from /lib64/libc.so.6
#6  0x0000003deac2b74e in __assert_fail_base () from /lib64/libc.so.6
#7  0x0000003deac2b810 in __assert_fail () from /lib64/libc.so.6
#8  0x000000000099b851 in lock_external (thd=0x237e3c0, tables=0x7fc5440727e8, count=3) at /pb2/build/sb_0-13562263-1414689457.82/mysqlcom-pro-5.6.22/sql/lock.cc:355
#9  0x000000000099b603 in mysql_lock_tables (thd=0x237e3c0, tables=0x7fc544069938, count=3, flags=0) at /pb2/build/sb_0-13562263-1414689457.82/mysqlcom-pro-5.6.22/sql/lock.cc:306
#10 0x00000000007c587d in lock_tables (thd=0x237e3c0, tables=0x7fc5440050d0, count=3, flags=0) at /pb2/build/sb_0-13562263-1414689457.82/mysqlcom-pro-5.6.22/sql/sql_base.cc:5968
#11 0x000000000080cb1c in mysql_insert (thd=0x237e3c0, table_list=0x7fc5440050d0, fields=..., values_list=..., update_fields=..., update_values=..., duplic=DUP_ERROR, ignore=false)
    at /pb2/build/sb_0-13562263-1414689457.82/mysqlcom-pro-5.6.22/sql/sql_insert.cc:908
#12 0x000000000082fe71 in mysql_execute_command (thd=0x237e3c0) at /pb2/build/sb_0-13562263-1414689457.82/mysqlcom-pro-5.6.22/sql/sql_parse.cc:3443
#13 0x00000000008380e1 in mysql_parse (thd=0x237e3c0, rawbuf=0x7fc544004fd0 "INSERT INTO t1 VALUES(1,1),(2,2),(3,1)", length=38, parser_state=0x7fc5725d9680)
    at /pb2/build/sb_0-13562263-1414689457.82/mysqlcom-pro-5.6.22/sql/sql_parse.cc:6357
#14 0x000000000082aa63 in dispatch_command (command=COM_QUERY, thd=0x237e3c0, packet=0x24ad431 "INSERT INTO t1 VALUES(1,1),(2,2),(3,1)", packet_length=38)
    at /pb2/build/sb_0-13562263-1414689457.82/mysqlcom-pro-5.6.22/sql/sql_parse.cc:1332
#15 0x0000000000829ac8 in do_command (thd=0x237e3c0) at /pb2/build/sb_0-13562263-1414689457.82/mysqlcom-pro-5.6.22/sql/sql_parse.cc:1034
#16 0x00000000007f0f17 in do_handle_one_connection (thd_arg=0x237e3c0) at /pb2/build/sb_0-13562263-1414689457.82/mysqlcom-pro-5.6.22/sql/sql_connect.cc:982
#17 0x00000000007f09e8 in handle_one_connection (arg=0x237e3c0) at /pb2/build/sb_0-13562263-1414689457.82/mysqlcom-pro-5.6.22/sql/sql_connect.cc:898
#18 0x0000000000e64c25 in pfs_spawn_thread (arg=0x2470b60) at /pb2/build/sb_0-13562263-1414689457.82/mysqlcom-pro-5.6.22/storage/perfschema/pfs.cc:1860
#19 0x0000003deb0079d1 in start_thread () from /lib64/libpthread.so.0
#20 0x0000003deace89dd in clone () from /lib64/libc.so.6
[7 Nov 2014 18:56] MySQL Verification Team
// 5.7.6 - only debug build affected

(gdb) bt
#0  0x0000003deb00c8ac in pthread_kill () from /lib64/libpthread.so.0
#1  0x0000000000f990a1 in my_write_core (sig=6) at /pb2/build/sb_0-13559856-1414670154.69/mysqlcom-pro-5.7.6-m16/mysys/stacktrace.c:247
#2  0x000000000092d7cc in handle_fatal_signal (sig=6) at /pb2/build/sb_0-13559856-1414670154.69/mysqlcom-pro-5.7.6-m16/sql/signal_handler.cc:219
#3  <signal handler called>
#4  0x0000003deac32625 in raise () from /lib64/libc.so.6
#5  0x0000003deac33e05 in abort () from /lib64/libc.so.6
#6  0x0000003deac2b74e in __assert_fail_base () from /lib64/libc.so.6
#7  0x0000003deac2b810 in __assert_fail () from /lib64/libc.so.6
#8  0x0000000000e2e125 in lock_external (thd=0x7f8ce0000d30, tables=0x7f8ce00575c8, count=3) at /pb2/build/sb_0-13559856-1414670154.69/mysqlcom-pro-5.7.6-m16/sql/lock.cc:348
#9  0x0000000000e2ded6 in mysql_lock_tables (thd=0x7f8ce0000d30, tables=0x7f8ce0062120, count=3, flags=0) at /pb2/build/sb_0-13559856-1414670154.69/mysqlcom-pro-5.7.6-m16/sql/lock.cc:299
#10 0x0000000000c3a7bb in lock_tables (thd=0x7f8ce0000d30, tables=0x7f8ce0005dd8, count=3, flags=0) at /pb2/build/sb_0-13559856-1414670154.69/mysqlcom-pro-5.7.6-m16/sql/sql_base.cc:6293
#11 0x0000000000e8fb2a in mysql_insert (thd=0x7f8ce0000d30, table_list=0x7f8ce0005dd8, fields=..., values_list=..., update_fields=..., update_values=..., duplic=DUP_ERROR)
    at /pb2/build/sb_0-13559856-1414670154.69/mysqlcom-pro-5.7.6-m16/sql/sql_insert.cc:557
#12 0x0000000000cb6855 in mysql_execute_command (thd=0x7f8ce0000d30) at /pb2/build/sb_0-13559856-1414670154.69/mysqlcom-pro-5.7.6-m16/sql/sql_parse.cc:3338
#13 0x0000000000cbce6a in mysql_parse (thd=0x7f8ce0000d30, parser_state=0x7f8d24d4a660) at /pb2/build/sb_0-13559856-1414670154.69/mysqlcom-pro-5.7.6-m16/sql/sql_parse.cc:5397
#14 0x0000000000cb0f2c in dispatch_command (command=COM_QUERY, thd=0x7f8ce0000d30, packet=0x7f8ce0009a61 "INSERT INTO t1 VALUES(1,1),(2,2),(3,1)", packet_length=38)
    at /pb2/build/sb_0-13559856-1414670154.69/mysqlcom-pro-5.7.6-m16/sql/sql_parse.cc:1249
#15 0x0000000000cafbd4 in do_command (thd=0x7f8ce0000d30) at /pb2/build/sb_0-13559856-1414670154.69/mysqlcom-pro-5.7.6-m16/sql/sql_parse.cc:833
#16 0x0000000000dbe89c in handle_connection (arg=0x43cee10) at /pb2/build/sb_0-13559856-1414670154.69/mysqlcom-pro-5.7.6-m16/sql/conn_handler/connection_handler_per_thread.cc:298
#17 0x000000000138347f in pfs_spawn_thread (arg=0x4225260) at /pb2/build/sb_0-13559856-1414670154.69/mysqlcom-pro-5.7.6-m16/storage/perfschema/pfs.cc:2137
#18 0x0000003deb0079d1 in start_thread () from /lib64/libpthread.so.0
#19 0x0000003deace89dd in clone () from /lib64/libc.so.6
[10 Jul 2015 15:44] Paul DuBois
Noted in 5.8.0 changelog.

Calling a procedure which created a view from a trigger, or creating
a function that called a procedure that executed RENAME TABLE could,
under certain circumstances, raise an assertion.