Bug #74604 Assertion `db_length == copy->db_length' failed in sql/sql_prepare.cc:3860
Submitted: 28 Oct 2014 13:29 Modified: 7 Sep 2017 7:51
Reporter: Ramesh Sivaraman Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: DDL Severity:S3 (Non-critical)
Version:5.6.20-debug, 5.6.22 OS:Linux (CentOS 7)
Assigned to: CPU Architecture:Any

[28 Oct 2014 13:29] Ramesh Sivaraman
Description:
mysqld: /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_prepare.cc:3860: void Prepared_statement::swap_prepared_statement(Prepared_statement*): Assertion `db_length == copy->db_length' failed.
13:20:52 UTC - mysqld got signal 6 ;

*** GDB info

#0  0x00007fca2a5f8771 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  0x00007fca294045c9 in raise () from /lib64/libc.so.6
#5  0x00007fca29405cd8 in abort () from /lib64/libc.so.6
#6  0x00007fca293fd536 in __assert_fail_base () from /lib64/libc.so.6
#7  0x00007fca293fd5e2 in __assert_fail () from /lib64/libc.so.6
#8  0x00000000007f0223 in Prepared_statement::swap_prepared_statement (this=0x7fc98dc7f280, copy=0x7fca2abee8c0) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_prepare.cc:3860
#9  0x00000000007efd4b in Prepared_statement::reprepare (this=0x7fc98dc7f280) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_prepare.cc:3762
#10 0x00000000007ef8b8 in Prepared_statement::execute_loop (this=0x7fc98dc7f280, expanded_query=0x7fca2abeecf0, open_cursor=false, packet=0x0, packet_end=0x0) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_prepare.cc:3675
#11 0x00000000007ed6f5 in mysql_sql_stmt_execute (thd=0x7fc997324000) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_prepare.cc:2755
#12 0x00000000007cf5f9 in mysql_execute_command (thd=0x7fc997324000) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_parse.cc:2659
#13 0x00000000007d8fa4 in mysql_parse (thd=0x7fc997324000, rawbuf=0x7fc98dc1f010 "execute sq", length=10, parser_state=0x7fca2abefe70) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_parse.cc:6245
#14 0x00000000007cc557 in dispatch_command (command=COM_QUERY, thd=0x7fc997324000, packet=0x7fc997362001 "execute sq", packet_length=10) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_parse.cc:1332
#15 0x00000000007cb646 in do_command (thd=0x7fc997324000) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_parse.cc:1034
#16 0x0000000000793a61 in do_handle_one_connection (thd_arg=0x7fc997324000) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_connect.cc:982
#17 0x000000000079354a in handle_one_connection (arg=0x7fc997324000) at /ssd/ramesh/mysql-server/mysql-5.6/sql/sql_connect.cc:898
#18 0x0000000000ad4b5c in pfs_spawn_thread (arg=0x7fca23f38b00) at /ssd/ramesh/mysql-server/mysql-5.6/storage/perfschema/pfs.cc:1860
#19 0x00007fca2a5f3df3 in start_thread () from /lib64/libpthread.so.0
#20 0x00007fca294c501d in clone () from /lib64/libc.so.6

How to repeat:
DROP DATABASE test;CREATE DATABASE test;USE test;
prepare sq from 'show status like "slow_queries"';
DROP database test;
set @@global.max_user_connections=@@local.max_join_size,@@local.max_join_size=@@global.max_user_connections;
execute sq;
execute sq;
[28 Oct 2014 14:36] MySQL Verification Team
Hello Ramesh Sivaraman,

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

Thanks,
Umesh
[28 Oct 2014 14:36] MySQL Verification Team
// 5.6.22 debug build

Version: '5.6.22-enterprise-commercial-advanced-debug'  socket: '/tmp/mysql.sock'  port: 3306  MySQL Enterprise Server - Advanced Edition Debug (Commercial)
mysqld-debug: /export/home/pb2/build/sb_0-13146752-1409933888.09/mysqlcom-pro-5.6.22/sql/sql_prepare.cc:3860: void Prepared_statement::swap_prepared_statement(Prepared_statement*): Assertion `db
_length == copy->db_length' failed.
05:37:33 UTC - mysqld got signal 6 ;

(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  0x000000000084eb3f in Prepared_statement::swap_prepared_statement (this=0x7fba340117e0, copy=0x7fba57007af0)
    at /export/home/pb2/build/sb_0-13146752-1409933888.09/mysqlcom-pro-5.6.22/sql/sql_prepare.cc:3860
#9  0x000000000084e68a in Prepared_statement::reprepare (this=0x7fba340117e0) at /export/home/pb2/build/sb_0-13146752-1409933888.09/mysqlcom-pro-5.6.22/sql/sql_prepare.cc:3762
#10 0x000000000084e1c2 in Prepared_statement::execute_loop (this=0x7fba340117e0, expanded_query=0x7fba57008010, open_cursor=false, packet=0x0, packet_end=0x0)
    at /export/home/pb2/build/sb_0-13146752-1409933888.09/mysqlcom-pro-5.6.22/sql/sql_prepare.cc:3675
#11 0x000000000084bfb8 in mysql_sql_stmt_execute (thd=0x8ba0ee0) at /export/home/pb2/build/sb_0-13146752-1409933888.09/mysqlcom-pro-5.6.22/sql/sql_prepare.cc:2755
#12 0x000000000082d584 in mysql_execute_command (thd=0x8ba0ee0) at /export/home/pb2/build/sb_0-13146752-1409933888.09/mysqlcom-pro-5.6.22/sql/sql_parse.cc:2659
#13 0x00000000008375d1 in mysql_parse (thd=0x8ba0ee0, rawbuf=0x7fba34004fd0 "execute sq", length=10, parser_state=0x7fba57009680)
    at /export/home/pb2/build/sb_0-13146752-1409933888.09/mysqlcom-pro-5.6.22/sql/sql_parse.cc:6245
#14 0x000000000082a3a2 in dispatch_command (command=COM_QUERY, thd=0x8ba0ee0, packet=0x8cd07f1 "execute sq", packet_length=10)
    at /export/home/pb2/build/sb_0-13146752-1409933888.09/mysqlcom-pro-5.6.22/sql/sql_parse.cc:1332
#15 0x0000000000829407 in do_command (thd=0x8ba0ee0) at /export/home/pb2/build/sb_0-13146752-1409933888.09/mysqlcom-pro-5.6.22/sql/sql_parse.cc:1034
#16 0x00000000007f0887 in do_handle_one_connection (thd_arg=0x8ba0ee0) at /export/home/pb2/build/sb_0-13146752-1409933888.09/mysqlcom-pro-5.6.22/sql/sql_connect.cc:982
#17 0x00000000007f0358 in handle_one_connection (arg=0x8ba0ee0) at /export/home/pb2/build/sb_0-13146752-1409933888.09/mysqlcom-pro-5.6.22/sql/sql_connect.cc:898
#18 0x0000000000e5c19d in pfs_spawn_thread (arg=0x8c93f20) at /export/home/pb2/build/sb_0-13146752-1409933888.09/mysqlcom-pro-5.6.22/storage/perfschema/pfs.cc:1860
#19 0x0000003bf26079d1 in start_thread () from /lib64/libpthread.so.0
#20 0x0000003bf22e886d in clone () from /lib64/libc.so.6
(gdb) quit
[28 Oct 2014 14:44] MySQL Verification Team
// 5.7.6 debug build affected

2014-10-30T05:47:22.121748Z 0 [Note] /data/ushastry/server/mysql-advanced-5.7.6/bin/mysqld-debug: ready for connections.
Version: '5.7.6-m16-enterprise-commercial-advanced-debug'  socket: '/tmp/mysql.sock'  port: 3306  MySQL Enterprise Server - Advanced Edition Debug (Commercial)
mysqld-debug: /pb2/build/sb_0-13146106-1409929295.44/mysqlcom-pro-5.7.6-m16/sql/sql_prepare.cc:3789: void Prepared_statement::swap_prepared_statement(Prepared_statement*): Assertion `m_db.length
 == copy->m_db.length' failed.

(gdb) bt
#0  0x0000003bf260c8ac in pthread_kill () from /lib64/libpthread.so.0
#1  0x0000000000e794c5 in my_write_core (sig=6) at /pb2/build/sb_0-13146106-1409929295.44/mysqlcom-pro-5.7.6-m16/mysys/stacktrace.c:247
#2  0x000000000086cb4e in handle_fatal_signal (sig=6) at /pb2/build/sb_0-13146106-1409929295.44/mysqlcom-pro-5.7.6-m16/sql/signal_handler.cc:219
#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  0x0000000000bcf633 in Prepared_statement::swap_prepared_statement (this=0x7fbfb8042670, copy=0x7fc07c0a7920)
    at /pb2/build/sb_0-13146106-1409929295.44/mysqlcom-pro-5.7.6-m16/sql/sql_prepare.cc:3789
#9  0x0000000000bcf0fd in Prepared_statement::reprepare (this=0x7fbfb8042670) at /pb2/build/sb_0-13146106-1409929295.44/mysqlcom-pro-5.7.6-m16/sql/sql_prepare.cc:3694
#10 0x0000000000bcec3c in Prepared_statement::execute_loop (this=0x7fbfb8042670, expanded_query=0x7fc07c0a7e10, open_cursor=false, packet=0x0, packet_end=0x0)
    at /pb2/build/sb_0-13146106-1409929295.44/mysqlcom-pro-5.7.6-m16/sql/sql_prepare.cc:3603
#11 0x0000000000bcc89f in mysql_sql_stmt_execute (thd=0x7fbfb8000d30) at /pb2/build/sb_0-13146106-1409929295.44/mysqlcom-pro-5.7.6-m16/sql/sql_prepare.cc:2658
#12 0x0000000000ba106a in mysql_execute_command (thd=0x7fbfb8000d30) at /pb2/build/sb_0-13146106-1409929295.44/mysqlcom-pro-5.7.6-m16/sql/sql_parse.cc:2502
#13 0x0000000000baa012 in mysql_parse (thd=0x7fbfb8000d30, parser_state=0x7fc07c0a9660) at /pb2/build/sb_0-13146106-1409929295.44/mysqlcom-pro-5.7.6-m16/sql/sql_parse.cc:5427
#14 0x0000000000b9dec7 in dispatch_command (command=COM_QUERY, thd=0x7fbfb8000d30, packet=0x7fbfb80098b1 "execute sq", packet_length=10)
    at /pb2/build/sb_0-13146106-1409929295.44/mysqlcom-pro-5.7.6-m16/sql/sql_parse.cc:1250
#15 0x0000000000b9cb7b in do_command (thd=0x7fbfb8000d30) at /pb2/build/sb_0-13146106-1409929295.44/mysqlcom-pro-5.7.6-m16/sql/sql_parse.cc:834
#16 0x0000000000caa2d8 in handle_connection (arg=0xc9cc3e0) at /pb2/build/sb_0-13146106-1409929295.44/mysqlcom-pro-5.7.6-m16/sql/conn_handler/connection_handler_per_thread.cc:298
#17 0x0000000001241f24 in pfs_spawn_thread (arg=0xc9b9530) at /pb2/build/sb_0-13146106-1409929295.44/mysqlcom-pro-5.7.6-m16/storage/perfschema/pfs.cc:2137
#18 0x0000003bf26079d1 in start_thread () from /lib64/libpthread.so.0
#19 0x0000003bf22e886d in clone () from /lib64/libc.so.6
[28 Feb 2015 6:02] Roel Van de Paar
Additional testcase found on 5.7.5-m15

DROP DATABASE test;CREATE DATABASE test;USE test;
SET MAX_JOIN_SIZE=2;
PREPARE f1 FROM 'SHOW COLUMNS FROM mysqltest2.t2';
DROP DATABASE test;
EXECUTE f1;
EXECUTE f1;
[7 Sep 2017 7:51] Havard Dybvik
Posted by developer:
 
Not reproducible on trunk as of commit db85366090b1b5380485076b6313649fd9945e8c. An error is returned instead of failing an assertion:

mysql> execute sq;
ERROR 1104 (42000): The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay