[MDEV-23391] Server crash in close_thread_table or Assertion `thd->mdl_context.is_lock_owner(MDL_key::TABLE, table->s->db.str, table->s->table_name.str, MDL_SHARED)' upon CREATE OR REPLACE TABLE under lock Created: 2020-08-03  Updated: 2021-10-26  Resolved: 2021-10-26

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Create Table, Locking
Affects Version/s: 10.1, 10.2, 10.3, 10.4, 10.5, 10.6
Fix Version/s: 10.2.41, 10.3.32, 10.4.22, 10.5.13, 10.6.5

Type: Bug Priority: Critical
Reporter: Elena Stepanova Assignee: Vladislav Vaintroub
Resolution: Fixed Votes: 0
Labels: affects-tests


 Description   

The assertion looks like MDEV-19273, but the rest – the location, scenario, affected versions – are completely different.

SET sql_mode= 'STRICT_TRANS_TABLES'; # Only needed for 10.1, in higher versions it is default
 
CREATE TABLE t1 (a INT);
LOCK TABLE t1 WRITE;
 
--error ER_DATA_TOO_LONG
CREATE OR REPLACE TABLE t1 (a CHAR(1)) AS SELECT 'foo' AS a;
 
# Cleanup
DROP TABLE t1;

10.2 release 5f1ec5cb

#3  <signal handler called>
#4  close_thread_table (thd=thd@entry=0x7fa8d80009a8, table_ptr=table_ptr@entry=0x7fa8d8000a88) at /data/src/10.2/sql/sql_base.cc:886
#5  0x0000560bb5d11e6c in drop_open_table (thd=0x7fa8d80009a8, table=<optimized out>, db_name=0x7fa8d800f808 "test", table_name=0x7fa8d800f1a0 "t1") at /data/src/10.2/sql/sql_base.cc:1272
#6  0x0000560bb5d3d7ce in select_create::abort_result_set (this=0x7fa8d800faa0) at /data/src/10.2/sql/sql_insert.cc:4721
#7  0x0000560bb5db2e5a in handle_select (thd=thd@entry=0x7fa8d80009a8, lex=lex@entry=0x7fa8d8004320, result=result@entry=0x7fa8d800faa0, setup_tables_done_option=setup_tables_done_option@entry=0) at /data/src/10.2/sql/sql_select.cc:379
#8  0x0000560bb5de6ed3 in Sql_cmd_create_table::execute (this=<optimized out>, thd=0x7fa8d80009a8) at /data/src/10.2/sql/sql_table.cc:10943
#9  0x0000560bb5d5c44a in mysql_execute_command (thd=thd@entry=0x7fa8d80009a8) at /data/src/10.2/sql/sql_parse.cc:5964
#10 0x0000560bb5d6370e in mysql_parse (thd=thd@entry=0x7fa8d80009a8, rawbuf=<optimized out>, length=59, parser_state=parser_state@entry=0x7fa92c93d620, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /data/src/10.2/sql/sql_parse.cc:7733
#11 0x0000560bb5d65fa0 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x7fa8d80009a8, packet=packet@entry=0x7fa8d8006d09 "CREATE OR REPLACE TABLE t1 (a CHAR(1)) AS SELECT 'foo' AS a", packet_length=packet_length@entry=59, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /data/src/10.2/sql/sql_parse.cc:1824
#12 0x0000560bb5d66d60 in do_command (thd=0x7fa8d80009a8) at /data/src/10.2/sql/sql_parse.cc:1377
#13 0x0000560bb5e33682 in do_handle_one_connection (connect=connect@entry=0x560bb8d97d88) at /data/src/10.2/sql/sql_connect.cc:1336
#14 0x0000560bb5e337dd in handle_one_connection (arg=arg@entry=0x560bb8d97d88) at /data/src/10.2/sql/sql_connect.cc:1241
#15 0x0000560bb63f4f01 in pfs_spawn_thread (arg=0x560bb8d97fe8) at /data/src/10.2/storage/perfschema/pfs.cc:1869
#16 0x00007fa9335124a4 in start_thread (arg=0x7fa92c93e700) at pthread_create.c:456
#17 0x00007fa932590d0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97

10.2 debug 6e09e7c1

mysqld: /data/src/10.2/sql/sql_base.cc:883: void close_thread_table(THD*, TABLE**): Assertion `thd->mdl_context.is_lock_owner(MDL_key::TABLE, table->s->db.str, table->s->table_name.str, MDL_SHARED)' failed.
200803 21:45:23 [ERROR] mysqld got signal 6 ;
 
#7  0x00007fdc12548f12 in __GI___assert_fail (assertion=0x555b6fc8db78 "thd->mdl_context.is_lock_owner(MDL_key::TABLE, table->s->db.str, table->s->table_name.str, MDL_SHARED)", file=0x555b6fc8d830 "/data/src/10.2/sql/sql_base.cc", line=883, function=0x555b6fc8f3a0 <close_thread_table(THD*, TABLE**)::__PRETTY_FUNCTION__> "void close_thread_table(THD*, TABLE**)") at assert.c:101
#8  0x0000555b6f1a62e6 in close_thread_table (thd=0x7fdbfc000af0, table_ptr=0x7fdbfc000bd0) at /data/src/10.2/sql/sql_base.cc:880
#9  0x0000555b6f1a6150 in close_thread_tables (thd=0x7fdbfc000af0) at /data/src/10.2/sql/sql_base.cc:859
#10 0x0000555b6f1a8c2f in Locked_tables_list::unlock_locked_tables (this=0x7fdbfc004558, thd=0x7fdbfc000af0) at /data/src/10.2/sql/sql_base.cc:2219
#11 0x0000555b6f1a8ca9 in Locked_tables_list::unlock_locked_table (this=0x7fdbfc004558, thd=0x7fdbfc000af0, mdl_ticket=0x7fdbfc010d70) at /data/src/10.2/sql/sql_base.cc:2261
#12 0x0000555b6f1ff49a in select_create::abort_result_set (this=0x7fdbfc012e48) at /data/src/10.2/sql/sql_insert.cc:4694
#13 0x0000555b6f257b24 in handle_select (thd=0x7fdbfc000af0, lex=0x7fdbfc004628, result=0x7fdbfc012e48, setup_tables_done_option=0) at /data/src/10.2/sql/sql_select.cc:379
#14 0x0000555b6f2f6edd in Sql_cmd_create_table::execute (this=0x7fdbfc012578, thd=0x7fdbfc000af0) at /data/src/10.2/sql/sql_table.cc:10944
#15 0x0000555b6f2222a2 in mysql_execute_command (thd=0x7fdbfc000af0) at /data/src/10.2/sql/sql_parse.cc:5964
#16 0x0000555b6f227223 in mysql_parse (thd=0x7fdbfc000af0, rawbuf=0x7fdbfc012458 "CREATE OR REPLACE TABLE t1 (a CHAR(1)) AS SELECT 'foo' AS a", length=59, parser_state=0x7fdc0c87c610, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:7733
#17 0x0000555b6f21554f in dispatch_command (command=COM_QUERY, thd=0x7fdbfc000af0, packet=0x7fdbfc08d321 "CREATE OR REPLACE TABLE t1 (a CHAR(1)) AS SELECT 'foo' AS a", packet_length=59, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:1824
#18 0x0000555b6f213fca in do_command (thd=0x7fdbfc000af0) at /data/src/10.2/sql/sql_parse.cc:1377
#19 0x0000555b6f36a099 in do_handle_one_connection (connect=0x555b72996cf0) at /data/src/10.2/sql/sql_connect.cc:1336
#20 0x0000555b6f369e04 in handle_one_connection (arg=0x555b72996cf0) at /data/src/10.2/sql/sql_connect.cc:1241
#21 0x0000555b6fb80aa8 in pfs_spawn_thread (arg=0x555b729a1ae0) at /data/src/10.2/storage/perfschema/pfs.cc:1869
#22 0x00007fdc144d14a4 in start_thread (arg=0x7fdc0c87d700) at pthread_create.c:456
#23 0x00007fdc12605d0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97

Reproducible on 10.1-10.5 with at least MyISAM, InnoDB, Aria, on debug and non-debug builds as described



 Comments   
Comment by Elena Stepanova [ 2020-09-15 ]

A slightly different test case causes a slightly different stack trace on debug builds. On 10.2-10.4 it's still very similar to the above, just shorter, while on 10.5 it happens in a different function.

CREATE TABLE t1 (a INT);
CREATE TABLE t2 (b INT);
LOCK TABLE t1 WRITE, t2 WRITE;
 
--error ER_DATA_TOO_LONG
CREATE OR REPLACE TABLE t1 (a CHAR(1)) AS SELECT 'foo' AS a;
 
# Cleanup
UNLOCK TABLES;
DROP TABLE IF EXISTS t1, t2;

10.2 debug 80075ba0

mysqld: /data/src/10.2/sql/sql_base.cc:880: void close_thread_table(THD*, TABLE**): Assertion `thd->mdl_context.is_lock_owner(MDL_key::TABLE, table->s->db.str, table->s->table_name.str, MDL_SHARED)' failed.
200916  0:23:53 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f680ea9ff36 in __GI___assert_fail (assertion=0x55898a86bc30 "thd->mdl_context.is_lock_owner(MDL_key::TABLE, table->s->db.str, table->s->table_name.str, MDL_SHARED)", file=0x55898a86b798 "/data/src/10.2/sql/sql_base.cc", line=880, function=0x55898a86bbb0 "void close_thread_table(THD*, TABLE**)") at assert.c:101
#8  0x0000558989d391af in close_thread_table (thd=0x7f67f8000d90, table_ptr=0x7f67f8000e70) at /data/src/10.2/sql/sql_base.cc:880
#9  0x0000558989d39def in drop_open_table (thd=0x7f67f8000d90, table=0x7f67f80a04a0, db_name=0x7f67f8012e50 "test", table_name=0x7f67f80127e8 "t1") at /data/src/10.2/sql/sql_base.cc:1272
#10 0x0000558989d93857 in select_create::abort_result_set (this=0x7f67f80130e8) at /data/src/10.2/sql/sql_insert.cc:4719
#11 0x0000558989decf48 in handle_select (thd=0x7f67f8000d90, lex=0x7f67f80048c8, result=0x7f67f80130e8, setup_tables_done_option=0) at /data/src/10.2/sql/sql_select.cc:379
#12 0x0000558989e8db19 in Sql_cmd_create_table::execute (this=0x7f67f8012818, thd=0x7f67f8000d90) at /data/src/10.2/sql/sql_table.cc:10944
#13 0x0000558989db6a41 in mysql_execute_command (thd=0x7f67f8000d90) at /data/src/10.2/sql/sql_parse.cc:5964
#14 0x0000558989dbba57 in mysql_parse (thd=0x7f67f8000d90, rawbuf=0x7f67f80126f8 "CREATE OR REPLACE TABLE t1 (a CHAR(1)) AS SELECT 'foo' AS a", length=59, parser_state=0x7f6808bfa5f0, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:7733
#15 0x0000558989da9d66 in dispatch_command (command=COM_QUERY, thd=0x7f67f8000d90, packet=0x7f67f8008b51 "CREATE OR REPLACE TABLE t1 (a CHAR(1)) AS SELECT 'foo' AS a", packet_length=59, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:1823
#16 0x0000558989da8861 in do_command (thd=0x7f67f8000d90) at /data/src/10.2/sql/sql_parse.cc:1377
#17 0x0000558989f02233 in do_handle_one_connection (connect=0x55898c383aa0) at /data/src/10.2/sql/sql_connect.cc:1336
#18 0x0000558989f01f98 in handle_one_connection (arg=0x55898c383aa0) at /data/src/10.2/sql/sql_connect.cc:1241
#19 0x000055898a726514 in pfs_spawn_thread (arg=0x55898c38c770) at /data/src/10.2/storage/perfschema/pfs.cc:1869
#20 0x00007f680efb1609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#21 0x00007f680eb8b103 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

10.5 debug 2bac9782

mariadbd: /data/src/10.5/sql/table_cache.cc:1253: void TDC_element::flush(THD*, bool): Assertion `thd->mdl_context.is_lock_owner(MDL_key::TABLE, share->db.str, share->table_name.str, MDL_EXCLUSIVE)' failed.
200916  0:26:19 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f6dbf767f36 in __GI___assert_fail (assertion=0x5625d608a3a8 "thd->mdl_context.is_lock_owner(MDL_key::TABLE, share->db.str, share->table_name.str, MDL_EXCLUSIVE)", file=0x5625d6089bb0 "/data/src/10.5/sql/table_cache.cc", line=1253, function=0x5625d608a548 "void TDC_element::flush(THD*, bool)") at assert.c:101
#8  0x00005625d53ef013 in TDC_element::flush (this=0x7f6da805c258, thd=0x7f6da8000db8, mark_flushed=true) at /data/src/10.5/sql/table_cache.cc:1253
#9  0x00005625d50af7ce in drop_open_table (thd=0x7f6da8000db8, table=0x7f6da80436a8, db_name=0x7f6da8014078, table_name=0x7f6da8014088) at /data/src/10.5/sql/sql_base.cc:1355
#10 0x00005625d5119702 in select_create::abort_result_set (this=0x7f6da80156c8) at /data/src/10.5/sql/sql_insert.cc:5092
#11 0x00005625d51a3ad9 in handle_select (thd=0x7f6da8000db8, lex=0x7f6da8004e88, result=0x7f6da80156c8, setup_tables_done_option=0) at /data/src/10.5/sql/sql_select.cc:435
#12 0x00005625d526a5ac in Sql_cmd_create_table_like::execute (this=0x7f6da8014000, thd=0x7f6da8000db8) at /data/src/10.5/sql/sql_table.cc:11964
#13 0x00005625d51659be in mysql_execute_command (thd=0x7f6da8000db8) at /data/src/10.5/sql/sql_parse.cc:5952
#14 0x00005625d516bdd2 in mysql_parse (thd=0x7f6da8000db8, rawbuf=0x7f6da8013f20 "CREATE OR REPLACE TABLE t1 (a CHAR(1)) AS SELECT 'foo' AS a", length=59, parser_state=0x7f6dba124510, is_com_multi=false, is_next_command=false) at /data/src/10.5/sql/sql_parse.cc:7994
#15 0x00005625d5158110 in dispatch_command (command=COM_QUERY, thd=0x7f6da8000db8, packet=0x7f6da8009099 "CREATE OR REPLACE TABLE t1 (a CHAR(1)) AS SELECT 'foo' AS a", packet_length=59, is_com_multi=false, is_next_command=false) at /data/src/10.5/sql/sql_parse.cc:1867
#16 0x00005625d5156904 in do_command (thd=0x7f6da8000db8) at /data/src/10.5/sql/sql_parse.cc:1348
#17 0x00005625d53026dc in do_handle_one_connection (connect=0x5625d85a2f68, put_in_cache=true) at /data/src/10.5/sql/sql_connect.cc:1410
#18 0x00005625d5302444 in handle_one_connection (arg=0x5625d8657d28) at /data/src/10.5/sql/sql_connect.cc:1312
#19 0x00005625d585cf15 in pfs_spawn_thread (arg=0x5625d85a2ba8) at /data/src/10.5/storage/perfschema/pfs.cc:2201
#20 0x00007f6dbfc7f609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#21 0x00007f6dbf853103 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Comment by Roel Van de Paar [ 2020-10-10 ]

SET SESSION default_storage_engine=mrg_myisam;
CREATE TABLE t (a INT);
LOCK TABLES t WRITE;
CREATE or REPLACE TABLE t AS SELECT 1 AS a;

Leads to:

10.5.6 2bac9782aa81ad386beaf00eb126ccf2d15031a1 (Optimized)

Core was generated by `/test/MD150920-mariadb-10.5.6-linux-x86_64-opt/bin/mysqld --no-defaults --core-'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=11)
    at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
[Current thread is 1 (Thread 0x14b4d0555700 (LWP 499383))]
(gdb) bt
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
#1  0x000055c8b63a4ae7 in my_write_core (sig=sig@entry=11) at /data/10.5_opt/mysys/stacktrace.c:424
#2  0x000055c8b5d73fda in handle_fatal_signal (sig=11) at /data/10.5_opt/sql/signal_handler.cc:330
#3  <signal handler called>
#4  close_thread_table (thd=thd@entry=0x14b4ac012018, table_ptr=table_ptr@entry=0x14b4ac0120f8) at /data/10.5_opt/sql/sql_base.cc:946
#5  0x000055c8b5b14cf9 in drop_open_table (thd=0x14b4ac012018, table=0x14b4ac05c418, db_name=0x14b4ac047168, table_name=0x14b4ac047178) at /data/10.5_opt/sql/sql_base.cc:1356
#6  0x000055c8b5b44236 in select_create::abort_result_set (this=0x14b4ac048590) at /data/10.5_opt/sql/sql_insert.cc:5092
#7  0x000055c8b5bd80ba in handle_select (thd=thd@entry=0x14b4ac012018, lex=lex@entry=0x14b4ac015f28, result=result@entry=0x14b4ac048590, setup_tables_done_option=setup_tables_done_option@entry=0) at /data/10.5_opt/sql/sql_select.cc:435
#8  0x000055c8b5c1019a in Sql_cmd_create_table_like::execute (this=<optimized out>, thd=0x14b4ac012018) at /data/10.5_opt/sql/sql_table.cc:11964
#9  0x000055c8b5b79eff in mysql_execute_command (thd=thd@entry=0x14b4ac012018) at /data/10.5_opt/sql/sql_parse.cc:5952
#10 0x000055c8b5b80a2c in mysql_parse (thd=0x14b4ac012018, rawbuf=<optimized out>, length=42, parser_state=0x14b4d0554430, is_com_multi=<optimized out>, is_next_command=<optimized out>) at /data/10.5_opt/sql/sql_parse.cc:7994
#11 0x000055c8b5b75cc5 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14b4ac012018, packet=packet@entry=0x14b4ac03a019 "CREATE or REPLACE TABLE t AS SELECT 1 AS a", packet_length=packet_length@entry=42, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /data/10.5_opt/sql/sql_parse.cc:1867
#12 0x000055c8b5b73fe4 in do_command (thd=0x14b4ac012018) at /data/10.5_opt/sql/sql_parse.cc:1348
#13 0x000055c8b5c6aba1 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x14b4cd4338f8, put_in_cache=put_in_cache@entry=true) at /data/10.5_opt/sql/sql_connect.cc:1410
#14 0x000055c8b5c6af14 in handle_one_connection (arg=arg@entry=0x14b4cd4338f8) at /data/10.5_opt/sql/sql_connect.cc:1312
#15 0x000055c8b5fdea4a in pfs_spawn_thread (arg=0x14b4cd44f018) at /data/10.5_opt/storage/perfschema/pfs.cc:2201
#16 0x000014b4cf4ce6db in start_thread (arg=0x14b4d0555700) at pthread_create.c:463
#17 0x000014b4ce8cca3f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

10.5.6 2bac9782aa81ad386beaf00eb126ccf2d15031a1 (Debug)

mysqld: /test/10.5_dbg/sql/sql_base.cc:943: void close_thread_table(THD*, TABLE**): Assertion `thd->mdl_context.is_lock_owner(MDL_key::TABLE, table->s->db.str, table->s->table_name.str, MDL_SHARED)' failed.

10.5.6 2bac9782aa81ad386beaf00eb126ccf2d15031a1 (Debug)

Core was generated by `/test/MD150920-mariadb-10.5.6-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
Program terminated with signal SIGABRT, Aborted.
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6)
    at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
[Current thread is 1 (Thread 0x1513508a0700 (LWP 607600))]
(gdb) bt
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
#1  0x000055a2721be85a in my_write_core (sig=sig@entry=6) at /test/10.5_dbg/mysys/stacktrace.c:424
#2  0x000055a2719853a9 in handle_fatal_signal (sig=6) at /test/10.5_dbg/sql/signal_handler.cc:330
#3  <signal handler called>
#4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#5  0x000015134eb368b1 in __GI_abort () at abort.c:79
#6  0x000015134eb2642a in __assert_fail_base (fmt=0x15134ecada38 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x55a272329ef8 "thd->mdl_context.is_lock_owner(MDL_key::TABLE, table->s->db.str, table->s->table_name.str, MDL_SHARED)", file=file@entry=0x55a272329ad0 "/test/10.5_dbg/sql/sql_base.cc", line=line@entry=943, function=function@entry=0x55a27232d720 <close_thread_table(THD*, TABLE**)::__PRETTY_FUNCTION__> "void close_thread_table(THD*, TABLE**)") at assert.c:92
#7  0x000015134eb264a2 in __GI___assert_fail (assertion=assertion@entry=0x55a272329ef8 "thd->mdl_context.is_lock_owner(MDL_key::TABLE, table->s->db.str, table->s->table_name.str, MDL_SHARED)", file=file@entry=0x55a272329ad0 "/test/10.5_dbg/sql/sql_base.cc", line=line@entry=943, function=function@entry=0x55a27232d720 <close_thread_table(THD*, TABLE**)::__PRETTY_FUNCTION__> "void close_thread_table(THD*, TABLE**)") at assert.c:101
#8  0x000055a27164b20c in close_thread_table (thd=thd@entry=0x15132c815088, table_ptr=table_ptr@entry=0x15132c815168) at /test/10.5_dbg/sql/sql_base.cc:940
#9  0x000055a27164b78a in close_thread_tables (thd=thd@entry=0x15132c815088) at /test/10.5_dbg/sql/sql_base.cc:919
#10 0x000055a27164cd68 in Locked_tables_list::unlock_locked_tables (this=this@entry=0x15132c819058, thd=thd@entry=0x15132c815088) at /test/10.5_dbg/sql/sql_base.cc:2359
#11 0x000055a27164ce4d in Locked_tables_list::unlock_locked_table (this=0x15132c819058, thd=0x15132c815088, mdl_ticket=<optimized out>) at /test/10.5_dbg/sql/sql_base.cc:2402
#12 0x000055a271690011 in select_create::abort_result_set (this=0x15132c875600) at /test/10.5_dbg/sql/sql_insert.cc:5063
#13 0x000055a271752152 in handle_select (thd=thd@entry=0x15132c815088, lex=lex@entry=0x15132c819158, result=result@entry=0x15132c875600, setup_tables_done_option=setup_tables_done_option@entry=0) at /test/10.5_dbg/sql/sql_select.cc:435
#14 0x000055a2717a7fb8 in Sql_cmd_create_table_like::execute (this=0x15132c874160, thd=0x15132c815088) at /test/10.5_dbg/sql/sql_table.cc:11964
#15 0x000055a2716d79b0 in mysql_execute_command (thd=thd@entry=0x15132c815088) at /test/10.5_dbg/sql/sql_parse.cc:5952
#16 0x000055a2716df324 in mysql_parse (thd=thd@entry=0x15132c815088, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x15135089f350, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_dbg/sql/sql_parse.cc:7994
#17 0x000055a2716cbd54 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x15132c815088, packet=packet@entry=0x15132c867089 "CREATE or REPLACE TABLE t AS SELECT 1 AS a", packet_length=packet_length@entry=42, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.5_dbg/sql/sql_parse.cc:1867
#18 0x000055a2716ca53e in do_command (thd=0x15132c815088) at /test/10.5_dbg/sql/sql_parse.cc:1348
#19 0x000055a271829893 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x15132f8d4808, put_in_cache=put_in_cache@entry=true) at /test/10.5_dbg/sql/sql_connect.cc:1410
#20 0x000055a271829fb7 in handle_one_connection (arg=arg@entry=0x15132f8d4808) at /test/10.5_dbg/sql/sql_connect.cc:1312
#21 0x000055a271c945c2 in pfs_spawn_thread (arg=0x15134d446508) at /test/10.5_dbg/storage/perfschema/pfs.cc:2201
#22 0x000015134f8196db in start_thread (arg=0x1513508a0700) at pthread_create.c:463
#23 0x000015134ec17a3f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.1.47 (dbg), 10.1.47 (opt), 10.2.34 (dbg), 10.2.34 (opt), 10.3.25 (dbg), 10.3.25 (opt), 10.4.15 (dbg), 10.4.15 (opt), 10.5.6 (dbg), 10.5.6 (opt), 10.6.0 (dbg), 10.6.0 (opt)

Bug confirmed not present in:
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.49 (dbg), 5.6.49 (opt), 5.7.31 (dbg), 5.7.31 (opt), 8.0.21 (dbg), 8.0.21 (opt)

Comment by Roel Van de Paar [ 2020-10-10 ]

This also looks very flaky:

10.5.6 2bac9782aa81ad386beaf00eb126ccf2d15031a1 (Optimized)

10.5.6>CREATE TABLE t1 (a INT);
Query OK, 0 rows affected (0.011 sec)
10.5.6>CREATE TABLE t2 (b INT);
Query OK, 0 rows affected (0.010 sec)
10.5.6>LOCK TABLE t1 WRITE, t2 WRITE;
Query OK, 0 rows affected (0.000 sec)
10.5.6>CREATE OR REPLACE TABLE t1 (a CHAR(1)) AS SELECT 'foo' AS a;
ERROR 1406 (22001): Data too long for column 'a' at row 1
10.5.6>CREATE OR REPLACE TABLE t1 (a CHAR(1)) AS SELECT 'foo' AS a;
ERROR 1100 (HY000): Table 't1' was not locked with LOCK TABLES    ### (!)
10.5.6>SHOW CREATE TABLE t1;
ERROR 1100 (HY000): Table 't1' was not locked with LOCK TABLES    ### (!)
10.5.6>LOCK TABLE t1 WRITE;
ERROR 1146 (42S02): Table 'test.t1' doesn't exist    ### (!)
10.5.6>SHOW CREATE TABLE t1;
ERROR 1146 (42S02): Table 'test.t1' doesn't exist    ### (!)

Debug just crashes on the first CREATE OR REPLACE statement.

Comment by Roel Van de Paar [ 2020-10-10 ]

Unique id's seen so far with all testcases:

SIGSEGV|close_thread_table|drop_open_table|select_create::abort_result_set|handle_select 
thd->mdl_context.is_lock_owner(MDL_key::TABLE, table->s->db.str, table->s->table_name.str, MDL_SHARED)|SIGABRT|close_thread_table|close_thread_tables|Locked_tables_list::unlock_locked_tables|Locked_tables_list::unlock_locked_table
thd->transaction->stmt.is_empty()|SIGABRT|Locked_tables_list::unlock_locked_tables|Locked_tables_list::unlock_locked_table|select_create::abort_result_set|handle_select                                                         
thd->mdl_context.is_lock_owner(MDL_key::TABLE, share->db.str, share->table_name.str, MDL_EXCLUSIVE)|SIGABRT|TDC_element::flush|drop_open_table|select_create::abort_result_set|handle_select 

Comment by Vladislav Vaintroub [ 2021-10-18 ]

sanja, could you please look at https://github.com/MariaDB/server/commit/23d91a3e1e5c8e070a7457e35e8c5923a7886c21

Comment by Vladislav Vaintroub [ 2021-10-18 ]

that ^ did not work, a test would fail. sanja, ignore for now.

Comment by Vladislav Vaintroub [ 2021-10-19 ]

Ok , this is now fixed in the attached commit https://github.com/MariaDB/server/commit/00e5bcac96f935b5628c82ab634c8b0b61f0dbdf

Comment by Oleksandr Byelkin [ 2021-10-26 ]

OK to push

Generated at Thu Feb 08 09:22:03 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.