[MDEV-15149] Assorted assertion failures upon concurrent creating / querying sequences (same test case) Created: 2018-01-31  Updated: 2018-03-29  Resolved: 2018-03-29

Status: Closed
Project: MariaDB Server
Component/s: Sequences
Affects Version/s: 10.3
Fix Version/s: 10.3.6

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


 Description   

The test is non-deterministic, run with --repeat=N.

--source include/have_innodb.inc
 
CREATE SEQUENCE s1 ENGINE=InnoDB;
CREATE SEQUENCE s2 ENGINE=InnoDB;
 
--connect (con1,localhost,root,,test)
--send
	CREATE TABLE s3 LIKE s2;
 
--connection default
CREATE SEQUENCE s4 ENGINE=InnoDB;
SELECT * from s1 WHERE start_value IN (SELECT start_value FROM s2);
 
--connection con1
--reap
 
# Cleanup
--disconnect con1
--connection default
DROP SEQUENCE s1, s2, s3, s4;

10.3 926adcfeeaf

Assertion `table_share->tmp_table != NO_TMP_TABLE || ((lock_type != 2 && m_lock_type == 2) || lock_type == 2)' failed
 
#3  0x00007f4701253ee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#4  0x000055df1afd3273 in handler::ha_thd (this=0x7f46a405f9e8) at /data/src/10.3/sql/handler.cc:2628
#5  0x000055df1b300618 in ha_innobase::table_flags (this=0x7f46a405f9e8) at /data/src/10.3/storage/innobase/handler/ha_innodb.cc:5242
#6  0x000055df1b777104 in ha_sequence::table_flags (this=0x7f46a405ea68) at /data/src/10.3/sql/ha_sequence.cc:281
#7  0x000055df1afdcb0d in handler::ha_external_lock (this=0x7f46a405ea68, thd=0x7f46a4000b00, lock_type=2) at /data/src/10.3/sql/handler.cc:6117
#8  0x000055df1b0f6202 in unlock_external (thd=0x7f46a4000b00, table=0x7f46a40160e8, count=1) at /data/src/10.3/sql/lock.cc:729
#9  0x000055df1b0f5615 in mysql_unlock_tables (thd=0x7f46a4000b00, sql_lock=0x7f46a40160a0, free_lock=false) at /data/src/10.3/sql/lock.cc:434
#10 0x000055df1b0f556d in mysql_unlock_tables (thd=0x7f46a4000b00, sql_lock=0x7f46a40160a0) at /data/src/10.3/sql/lock.cc:420
#11 0x000055df1ac60718 in close_thread_tables (thd=0x7f46a4000b00) at /data/src/10.3/sql/sql_base.cc:840
#12 0x000055df1aee9205 in sequence_insert (thd=0x7f46a4000b00, lex=0x7f46a40047c8, table_list=0x7f46a4013a98) at /data/src/10.3/sql/sql_sequence.cc:337
#13 0x000055df1adb8300 in mysql_create_table_no_lock (thd=0x7f46a4000b00, db=0x7f46a40140c8 "test", table_name=0x7f46a4013a60 "s3", create_info=0x7f46ec5a6010, alter_info=0x7f46ec5a5f60, is_trans=0x7f46ec5a5eb4, create_table_mode=0, table_list=0x7f46a4013a98) at /data/src/10.3/sql/sql_table.cc:5112
#14 0x000055df1adb9fa8 in mysql_create_like_table (thd=0x7f46a4000b00, table=0x7f46a4013a98, src_table=0x7f46a4014108, create_info=0x7f46ec5a77b0) at /data/src/10.3/sql/sql_table.cc:5696
#15 0x000055df1ace8bcd in mysql_execute_command (thd=0x7f46a4000b00) at /data/src/10.3/sql/sql_parse.cc:4239
#16 0x000055df1acf4a66 in mysql_parse (thd=0x7f46a4000b00, rawbuf=0x7f46a40139c0 "CREATE TABLE s3 LIKE s2", length=23, parser_state=0x7f46ec5a85f0, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:7988
#17 0x000055df1ace227f in dispatch_command (command=COM_QUERY, thd=0x7f46a4000b00, packet=0x7f46a400b141 "CREATE TABLE s3 LIKE s2", packet_length=23, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:1826
#18 0x000055df1ace0cb3 in do_command (thd=0x7f46a4000b00) at /data/src/10.3/sql/sql_parse.cc:1370
#19 0x000055df1ae48796 in do_handle_one_connection (connect=0x55df1e8dad30) at /data/src/10.3/sql/sql_connect.cc:1401
#20 0x000055df1ae48523 in handle_one_connection (arg=0x55df1e8dad30) at /data/src/10.3/sql/sql_connect.cc:1307
#21 0x000055df1b2e60b8 in pfs_spawn_thread (arg=0x55df1e8f82d0) at /data/src/10.3/storage/perfschema/pfs.cc:1862
#22 0x00007f4702f2a494 in start_thread (arg=0x7f46ec5a9700) at pthread_create.c:333
#23 0x00007f470131093f in clone () from /lib/x86_64-linux-gnu/libc.so.6

mysqld: /data/src/10.3/sql/handler.cc:2628: THD* handler::ha_thd() const: Assertion `!table || !table->in_use || table->in_use == _current_thd()' failed.
180131 18:02:52 [ERROR] mysqld got signal 6 ;
 
#7  0x00007fcaf939cee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#8  0x000055a1cef95273 in handler::ha_thd (this=0x7fca9c01ee58) at /data/src/10.3/sql/handler.cc:2628
#9  0x000055a1cf2c2618 in ha_innobase::table_flags (this=0x7fca9c01ee58) at /data/src/10.3/storage/innobase/handler/ha_innodb.cc:5242
#10 0x000055a1cf739104 in ha_sequence::table_flags (this=0x7fca9c05f738) at /data/src/10.3/sql/ha_sequence.cc:281
#11 0x000055a1cef9eb0d in handler::ha_external_lock (this=0x7fca9c05f738, thd=0x7fca9c000b00, lock_type=2) at /data/src/10.3/sql/handler.cc:6117
#12 0x000055a1cf0b8202 in unlock_external (thd=0x7fca9c000b00, table=0x7fca9c0160e8, count=1) at /data/src/10.3/sql/lock.cc:729
#13 0x000055a1cf0b7615 in mysql_unlock_tables (thd=0x7fca9c000b00, sql_lock=0x7fca9c0160a0, free_lock=false) at /data/src/10.3/sql/lock.cc:434
#14 0x000055a1cf0b756d in mysql_unlock_tables (thd=0x7fca9c000b00, sql_lock=0x7fca9c0160a0) at /data/src/10.3/sql/lock.cc:420
#15 0x000055a1cec22718 in close_thread_tables (thd=0x7fca9c000b00) at /data/src/10.3/sql/sql_base.cc:840
#16 0x000055a1ceeab205 in sequence_insert (thd=0x7fca9c000b00, lex=0x7fca9c0047c8, table_list=0x7fca9c013a98) at /data/src/10.3/sql/sql_sequence.cc:337
#17 0x000055a1ced7a300 in mysql_create_table_no_lock (thd=0x7fca9c000b00, db=0x7fca9c0140c8 "test", table_name=0x7fca9c013a60 "s3", create_info=0x7fcaec11a010, alter_info=0x7fcaec119f60, is_trans=0x7fcaec119eb4, create_table_mode=0, table_list=0x7fca9c013a98) at /data/src/10.3/sql/sql_table.cc:5112
#18 0x000055a1ced7bfa8 in mysql_create_like_table (thd=0x7fca9c000b00, table=0x7fca9c013a98, src_table=0x7fca9c014108, create_info=0x7fcaec11b7b0) at /data/src/10.3/sql/sql_table.cc:5696
#19 0x000055a1cecaabcd in mysql_execute_command (thd=0x7fca9c000b00) at /data/src/10.3/sql/sql_parse.cc:4239
#20 0x000055a1cecb6a66 in mysql_parse (thd=0x7fca9c000b00, rawbuf=0x7fca9c0139c0 "CREATE TABLE s3 LIKE s2", length=23, parser_state=0x7fcaec11c5f0, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:7988
#21 0x000055a1ceca427f in dispatch_command (command=COM_QUERY, thd=0x7fca9c000b00, packet=0x7fca9c00b141 "CREATE TABLE s3 LIKE s2", packet_length=23, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:1826
#22 0x000055a1ceca2cb3 in do_command (thd=0x7fca9c000b00) at /data/src/10.3/sql/sql_parse.cc:1370
#23 0x000055a1cee0a796 in do_handle_one_connection (connect=0x55a1d1d38d30) at /data/src/10.3/sql/sql_connect.cc:1401
#24 0x000055a1cee0a523 in handle_one_connection (arg=0x55a1d1d38d30) at /data/src/10.3/sql/sql_connect.cc:1307
#25 0x000055a1cf2a80b8 in pfs_spawn_thread (arg=0x55a1d1d562d0) at /data/src/10.3/storage/perfschema/pfs.cc:1862
#26 0x00007fcafb073494 in start_thread (arg=0x7fcaec11d700) at pthread_create.c:333
#27 0x00007fcaf945993f in clone () from /lib/x86_64-linux-gnu/libc.so.6

mysqld: /data/src/10.3/sql/sql_base.cc:3585: bool open_and_process_table(THD*, LEX*, TABLE_LIST*, uint*, uint, Prelocking_strategy*, bool, Open_table_context*): Assertion `tables->table->pos_in_table_list == tables' failed.
180131 18:03:32 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f84994ccee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#8  0x000055fa6594bb65 in open_and_process_table (thd=0x7f8444000b00, lex=0x7f84440047c8, tables=0x7f8444014108, counter=0x7f848c07aab4, flags=2080, prelocking_strategy=0x7f848c07ab30, has_prelocking_list=false, ot_ctx=0x7f848c07aa20) at /data/src/10.3/sql/sql_base.cc:3585
#9  0x000055fa6594c97e in open_tables (thd=0x7f8444000b00, options=..., start=0x7f848c07aa98, counter=0x7f848c07aab4, flags=2080, prelocking_strategy=0x7f848c07ab30) at /data/src/10.3/sql/sql_base.cc:4004
#10 0x000055fa6594e73c in open_and_lock_tables (thd=0x7f8444000b00, options=..., tables=0x7f8444013a98, derived=false, flags=2080, prelocking_strategy=0x7f848c07ab30) at /data/src/10.3/sql/sql_base.cc:4884
#11 0x000055fa65940cf3 in open_and_lock_tables (thd=0x7f8444000b00, tables=0x7f8444013a98, derived=false, flags=2080) at /data/src/10.3/sql/sql_base.h:498
#12 0x000055fa65bcf0fe in sequence_insert (thd=0x7f8444000b00, lex=0x7f84440047c8, table_list=0x7f8444013a98) at /data/src/10.3/sql/sql_sequence.cc:311
#13 0x000055fa65a9e300 in mysql_create_table_no_lock (thd=0x7f8444000b00, db=0x7f84440140c8 "test", table_name=0x7f8444013a60 "s3", create_info=0x7f848c07b010, alter_info=0x7f848c07af60, is_trans=0x7f848c07aeb4, create_table_mode=0, table_list=0x7f8444013a98) at /data/src/10.3/sql/sql_table.cc:5112
#14 0x000055fa65a9ffa8 in mysql_create_like_table (thd=0x7f8444000b00, table=0x7f8444013a98, src_table=0x7f8444014108, create_info=0x7f848c07c7b0) at /data/src/10.3/sql/sql_table.cc:5696
#15 0x000055fa659cebcd in mysql_execute_command (thd=0x7f8444000b00) at /data/src/10.3/sql/sql_parse.cc:4239
#16 0x000055fa659daa66 in mysql_parse (thd=0x7f8444000b00, rawbuf=0x7f84440139c0 "CREATE TABLE s3 LIKE s2", length=23, parser_state=0x7f848c07d5f0, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:7988
#17 0x000055fa659c827f in dispatch_command (command=COM_QUERY, thd=0x7f8444000b00, packet=0x7f844400b141 "CREATE TABLE s3 LIKE s2", packet_length=23, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:1826
#18 0x000055fa659c6cb3 in do_command (thd=0x7f8444000b00) at /data/src/10.3/sql/sql_parse.cc:1370
#19 0x000055fa65b2e796 in do_handle_one_connection (connect=0x55fa695a5d30) at /data/src/10.3/sql/sql_connect.cc:1401
#20 0x000055fa65b2e523 in handle_one_connection (arg=0x55fa695a5d30) at /data/src/10.3/sql/sql_connect.cc:1307
#21 0x000055fa65fcc0b8 in pfs_spawn_thread (arg=0x55fa695c32d0) at /data/src/10.3/storage/perfschema/pfs.cc:1862
#22 0x00007f849b1a3494 in start_thread (arg=0x7f848c07e700) at pthread_create.c:333
#23 0x00007f849958993f in clone () from /lib/x86_64-linux-gnu/libc.so.6



 Comments   
Comment by Michael Widenius [ 2018-03-29 ]

Problem was that sequence_insert closed and reopened the like table without proper locking.
Fixed by ensuring that the like table is not reopened in sequence_insert

Comment by Michael Widenius [ 2018-03-29 ]

Fixed and pushed

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