[MDEV-16929] Assertion `thd->transaction.stmt.is_empty() || thd->in_sub_stmt || (thd->state_flags & Open_tables_state::BACKUPS_AVAIL)' fails in close_thread_tables upon killing connection running SHOW on sequence Created: 2018-08-09  Updated: 2023-12-07

Status: Stalled
Project: MariaDB Server
Component/s: Admin statements, Sequences
Affects Version/s: 10.3, 10.4, 10.5
Fix Version/s: 10.4, 10.5

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

Issue Links:
Relates
relates to MDEV-20750 Assertion `thd->transaction.stmt.is_e... Open
relates to MDEV-23145 Server crashes in handler::update_glo... Open

 Description   

--source include/have_innodb.inc
 
CREATE SEQUENCE s ENGINE=InnoDB;
FLUSH TABLES WITH READ LOCK;
SET SESSION MAX_SESSION_MEM_USED= @@MAX_SESSION_MEM_USED + 1024;
SHOW CREATE SEQUENCE s;
 
# Cleanup
UNLOCK TABLES;
DROP SEQUENCE s;

10.3 debug f3f23b5c

mysqld: /data/src/10.3/sql/sql_base.cc:744: void close_thread_tables(THD*): Assertion `thd->transaction.stmt.is_empty() || thd->in_sub_stmt || (thd->state_flags & Open_tables_state::BACKUPS_AVAIL)' failed.
 
#7  0x00007efd0cbccf12 in __GI___assert_fail (assertion=0x557a0ba07010 "thd->transaction.stmt.is_empty() || thd->in_sub_stmt || (thd->state_flags & Open_tables_state::BACKUPS_AVAIL)", file=0x557a0ba06dd8 "/data/src/10.3/sql/sql_base.cc", line=744, function=0x557a0ba08b90 <close_thread_tables(THD*)::__PRETTY_FUNCTION__> "void close_thread_tables(THD*)") at assert.c:101
#8  0x0000557a0ad1c19a in close_thread_tables (thd=0x7efcbc000af0) at /data/src/10.3/sql/sql_base.cc:743
#9  0x0000557a0ae54710 in mysqld_show_create (thd=0x7efcbc000af0, table_list=0x7efcbc0128f0) at /data/src/10.3/sql/sql_show.cc:1450
#10 0x0000557a0adb7756 in mysql_execute_command (thd=0x7efcbc000af0) at /data/src/10.3/sql/sql_parse.cc:4245
#11 0x0000557a0adc3ea3 in mysql_parse (thd=0x7efcbc000af0, rawbuf=0x7efcbc012818 "SHOW CREATE SEQUENCE s", length=22, parser_state=0x7efd01f485e0, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:7810
#12 0x0000557a0adb06ea in dispatch_command (command=COM_QUERY, thd=0x7efcbc000af0, packet=0x7efcbc165811 "SHOW CREATE SEQUENCE s", packet_length=22, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:1848
#13 0x0000557a0adaf002 in do_command (thd=0x7efcbc000af0) at /data/src/10.3/sql/sql_parse.cc:1393
#14 0x0000557a0af284d7 in do_handle_one_connection (connect=0x557a0daa62b0) at /data/src/10.3/sql/sql_connect.cc:1403
#15 0x0000557a0af28239 in handle_one_connection (arg=0x557a0daa62b0) at /data/src/10.3/sql/sql_connect.cc:1308
#16 0x0000557a0b8df0e8 in pfs_spawn_thread (arg=0x557a0dac1260) at /data/src/10.3/storage/perfschema/pfs.cc:1869
#17 0x00007efd0eb554a4 in start_thread (arg=0x7efd01f49700) at pthread_create.c:456
#18 0x00007efd0cc89d0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97
 
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0x7efcbc012818): SHOW CREATE SEQUENCE s
Connection ID (thread ID): 9
Status: KILL_QUERY

10.3 non-debug f3f23b5c

MariaDB [test]> SHOW CREATE SEQUENCE s;
ERROR 1290 (HY000): The MariaDB server is running with the --max-thread-mem-used=9223372036854776831 option so it cannot execute this statement

I'm not sure whether the non-debug error above is expected.

Here is an alternative test case, which doesn't involve tampering with system variables – it's non-deterministic, run with --repeat=N.

--source include/have_innodb.inc
 
CREATE SEQUENCE s ENGINE=InnoDB;
RENAME TABLE s TO s1;
 
--connect (con1,localhost,root,,test)
--let $conid= `SELECT CONNECTION_ID()`
--send
  SHOW CREATE SEQUENCE s1;
 
--connection default
--eval KILL $conid
 
# Cleanup
--connection default
DROP SEQUENCE s1;

10.3 f1309fac

mysqld: /data/src/10.3/sql/sql_base.cc:744: void close_thread_tables(THD*): Assertion `thd->transaction.stmt.is_empty() || thd->in_sub_stmt || (thd->state_flags & Open_tables_state::BACKUPS_AVAIL)' failed.
190912 17:08:34 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f6391d3cf12 in __GI___assert_fail (assertion=0x5572e52cda48 "thd->transaction.stmt.is_empty() || thd->in_sub_stmt || (thd->state_flags & Open_tables_state::BACKUPS_AVAIL)", file=0x5572e52cd7c0 "/data/src/10.3/sql/sql_base.cc", line=744, function=0x5572e52cf510 <close_thread_tables(THD*)::__PRETTY_FUNCTION__> "void close_thread_tables(THD*)") at assert.c:101
#8  0x00005572e45b480d in close_thread_tables (thd=0x7f6334000b00) at /data/src/10.3/sql/sql_base.cc:743
#9  0x00005572e46ec9c5 in mysqld_show_create (thd=0x7f6334000b00, table_list=0x7f6334011530) at /data/src/10.3/sql/sql_show.cc:1449
#10 0x00005572e4650392 in mysql_execute_command (thd=0x7f6334000b00) at /data/src/10.3/sql/sql_parse.cc:4250
#11 0x00005572e465c9fd in mysql_parse (thd=0x7f6334000b00, rawbuf=0x7f6334011458 "SHOW CREATE SEQUENCE s1", length=23, parser_state=0x7f638c0f05e0, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:7830
#12 0x00005572e46492fb in dispatch_command (command=COM_QUERY, thd=0x7f6334000b00, packet=0x7f6334008c71 "SHOW CREATE SEQUENCE s1", packet_length=23, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:1856
#13 0x00005572e4647c22 in do_command (thd=0x7f6334000b00) at /data/src/10.3/sql/sql_parse.cc:1401
#14 0x00005572e47c0d40 in do_handle_one_connection (connect=0x5572e89ad0b0) at /data/src/10.3/sql/sql_connect.cc:1403
#15 0x00005572e47c0aa2 in handle_one_connection (arg=0x5572e89ad0b0) at /data/src/10.3/sql/sql_connect.cc:1308
#16 0x00005572e51a30a0 in pfs_spawn_thread (arg=0x5572e88f0aa0) at /data/src/10.3/storage/perfschema/pfs.cc:1862
#17 0x00007f63938b14a4 in start_thread (arg=0x7f638c0f1700) at pthread_create.c:456
#18 0x00007f6391df9d0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97

Reproducible on 10.3-10.5.
Couldn't reproduce with MyISAM.


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