[MDEV-15753] Assertion `thd->is_error()' failed in mysql_admin_table upon shutdown Created: 2018-04-02  Updated: 2023-08-24  Resolved: 2023-08-24

Status: Closed
Project: MariaDB Server
Component/s: Admin statements
Affects Version/s: 10.1, 10.2, 10.3
Fix Version/s: N/A

Type: Bug Priority: Minor
Reporter: Elena Stepanova Assignee: Vladislav Vaintroub
Resolution: Won't Fix Votes: 0
Labels: None


 Description   

Note: The test case is non-deterministic, run with --repeat=N and --mem. It currently fails almost every time for me on 10.2 and 10.3 in memory, but not on disk; and doesn't fail on 10.1, even though the failure was observed on 10.1 in the past.

--source include/have_innodb.inc
--source include/have_sequence.inc
 
SET GLOBAL innodb_stats_persistent= ON;
CREATE TABLE t1 (id int, a int, PRIMARY KEY (id)) ENGINE=InnoDB;
INSERT INTO t1 SELECT seq, seq FROM seq_1_to_10000;
CREATE DATABASE db;
FLUSH TABLES WITH READ LOCK;
 
--connect (con1,localhost,root,,test)
--connect (con2,localhost,root,,test)
--connect (con3,localhost,root,,test)
--send
  OPTIMIZE TABLE t1;
 
--connection con2
--send
  REPLACE INTO t1 SELECT * FROM t1;
 
--connection default
UNLOCK TABLES;
CREATE TABLE db.t ENGINE=InnoDB SELECT DISTINCT a FROM t1 WHERE id BETWEEN 5763 AND 58276 ORDER BY a;
--send
  CREATE DATABASE IF NOT EXISTS db;
 
--connection con1
--send
  UPDATE db.t SET a = a + 9999 WHERE a NOT IN ( SELECT DISTINCT a FROM t1 WHERE id BETWEEN 5763 AND 58276 ORDER BY a );
 
--connection default
--reap
SET lock_wait_timeout= 1;
--error 0,ER_LOCK_WAIT_TIMEOUT
FLUSH TABLES;
 
--source include/restart_mysqld.inc
 
# Cleanup
DROP DATABASE db;
DROP TABLE t1;

10.2 debug 7a695d8a

2020-06-12  1:44:56 140665977317120 [Note] /data/bld/10.2-debug/bin/mysqld (initiated by: root[root] @ localhost []): Normal shutdown
mysqld: /data/src/10.2/sql/sql_admin.cc:1066: bool mysql_admin_table(THD*, TABLE_LIST*, HA_CHECK_OPT*, const char*, thr_lock_type, bool, bool, uint, int (*)(THD*, TABLE
_LIST*, HA_CHECK_OPT*), int (handler::*)(THD*, HA_CHECK_OPT*), int (*)(THD*, TABLE_LIST*, HA_CHECK_OPT*)): Assertion `thd->is_error()' failed.
200612  1:44:56 [ERROR] mysqld got signal 6 ;
 
#6  0x00007fef5f4a0e67 in __assert_fail_base (fmt=<optimized out>, assertion=assertion@entry=0x563c619df473 "thd->is_error()", file=file@entry=0x563c619dee90 "/data/src/10.2/sql/sql_admin.cc", line=line@entry=1066, function=function@entry=0x563c619df6e0 <mysql_admin_table(THD*, TABLE_LIST*, st_ha_check_opt*, char const*, thr_lock_type, bool, bool, unsigned int, int (*)(THD*, TABLE_LIST*, st_ha_check_opt*), int (handler::*)(THD*, st_ha_check_opt*), int (*)(THD*, TABLE_LIST*, st_ha_check_opt*))::__PRETTY_FUNCTION__> "bool mysql_admin_table(THD*, TABLE_LIST*, HA_CHECK_OPT*, const char*, thr_lock_type, bool, bool, uint, int (*)(THD*, TABLE_LIST*, HA_CHECK_OPT*), int (handler::*)(THD*, HA_CHECK_OPT*), int (*)(THD*, T"...) at assert.c:92
#7  0x00007fef5f4a0f12 in __GI___assert_fail (assertion=0x563c619df473 "thd->is_error()", file=0x563c619dee90 "/data/src/10.2/sql/sql_admin.cc", line=1066, function=0x563c619df6e0 <mysql_admin_table(THD*, TABLE_LIST*, st_ha_check_opt*, char const*, thr_lock_type, bool, bool, unsigned int, int (*)(THD*, TABLE_LIST*, st_ha_check_opt*), int (handler::*)(THD*, st_ha_check_opt*), int (*)(THD*, TABLE_LIST*, st_ha_check_opt*))::__PRETTY_FUNCTION__> "bool mysql_admin_table(THD*, TABLE_LIST*, HA_CHECK_OPT*, const char*, thr_lock_type, bool, bool, uint, int (*)(THD*, TABLE_LIST*, HA_CHECK_OPT*), int (handler::*)(THD*, HA_CHECK_OPT*), int (*)(THD*, T"...) at assert.c:101
#8  0x0000563c6108a7d9 in mysql_admin_table(THD *, TABLE_LIST *, HA_CHECK_OPT *, const char *, thr_lock_type, bool, bool, uint, int (*)(THD *, TABLE_LIST *, HA_CHECK_OPT *), struct {...}, int (*)(THD *, TABLE_LIST *, HA_CHECK_OPT *)) (thd=0x7fef04000af0, tables=0x7fef04011158, check_opt=0x7fef04005600, operator_name=0x563c619df5d0 "optimize", lock_type=TL_WRITE, org_open_for_modify=true, repair_table_use_frm=false, extra_open_options=0, prepare_func=0x0, operator_func=(int (handler::*)(handler * const, THD *, HA_CHECK_OPT *)) 0x563c611aa80a <handler::ha_optimize(THD*, st_ha_check_opt*)>, view_operator_func=0x0) at /data/src/10.2/sql/sql_admin.cc:1066
#9  0x0000563c6108b862 in Sql_cmd_optimize_table::execute (this=0x7fef04011778, thd=0x7fef04000af0) at /data/src/10.2/sql/sql_admin.cc:1360
#10 0x0000563c60f2fba5 in mysql_execute_command (thd=0x7fef04000af0) at /data/src/10.2/sql/sql_parse.cc:5972
#11 0x0000563c60f34b25 in mysql_parse (thd=0x7fef04000af0, rawbuf=0x7fef04011088 "OPTIMIZE TABLE t1", length=17, parser_state=0x7fef59a0c610, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:7741
#12 0x0000563c60f22e52 in dispatch_command (command=COM_QUERY, thd=0x7fef04000af0, packet=0x7fef040088a1 "", packet_length=17, is_com_multi=false, is_next_command=false) at /data/src/10.2/sql/sql_parse.cc:1832
#13 0x0000563c60f218cd in do_command (thd=0x7fef04000af0) at /data/src/10.2/sql/sql_parse.cc:1385
#14 0x0000563c61077523 in do_handle_one_connection (connect=0x563c6442b360) at /data/src/10.2/sql/sql_connect.cc:1336
#15 0x0000563c6107728e in handle_one_connection (arg=0x563c6442b360) at /data/src/10.2/sql/sql_connect.cc:1241
#16 0x0000563c6188d7d0 in pfs_spawn_thread (arg=0x563c6442ae50) at /data/src/10.2/storage/perfschema/pfs.cc:1869
#17 0x00007fef614294a4 in start_thread (arg=0x7fef59a0d700) at pthread_create.c:456
#18 0x00007fef5f55dd0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97
 
Query (0x7fef04011088): OPTIMIZE TABLE t1
Connection ID (thread ID): 12
Status: KILL_SERVER

No obvious problem on a non-debug build.
Couldn't reproduce on 10.4 or 10.5.



 Comments   
Comment by Alice Sherepa [ 2022-07-01 ]

I've got it on bb-10.10-MDEV-23287, based on 10.10:

bb-10.10-MDEV-23287 d11722e7076015f1641688b8

mysqld: 10.10/sql/sql_admin.cc:1173: bool mysql_admin_table(THD*, TABLE_LIST*, HA_CHECK_OPT*, const LEX_CSTRING*, thr_lock_type, bool, bool, uint, int (*)(THD*, TABLE_LIST*, HA_CHECK_OPT*), int (handler::*)(THD*, HA_CHECK_OPT*), int (*)(THD*, TABLE_LIST*, HA_CHECK_OPT*), bool): Assertion `thd->is_error()' failed.
220701 14:15:26 [ERROR] mysqld got signal 6 ;
 
Server version: 10.10.0-MariaDB-debug-log
 
linux/raise.c:51(__GI_raise)[0x7fe28fa9f7bb]
stdlib/abort.c:81(__GI_abort)[0x7fe28fa8a535]
sql/sql_admin.cc:1174(mysql_admin_table(THD*, TABLE_LIST*, st_ha_check_opt*, st_mysql_const_lex_string const*, thr_lock_type, bool, bool, unsigned int, int (*)(THD*, TABLE_LIST*, st_ha_check_opt*), int (handler::*)(THD*, st_ha_check_opt*), int (*)(THD*, TABLE_LIST*, st_ha_check_opt*), bool))[0x55c5a62e00e8]
sql/sql_admin.cc:1513(Sql_cmd_optimize_table::execute(THD*))[0x55c5a62e2e67]
sql/sql_parse.cc:5996(mysql_execute_command(THD*, bool))[0x55c5a5e26725]
sql/sql_parse.cc:8036(mysql_parse(THD*, char*, unsigned int, Parser_state*))[0x55c5a5e339f5]
sql/sql_parse.cc:1896(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool))[0x55c5a5e0a0a1]
sql/sql_parse.cc:1407(do_command(THD*, bool))[0x55c5a5e06dd7]
sql/sql_connect.cc:1418(do_handle_one_connection(CONNECT*, bool))[0x55c5a62a391f]
sql/sql_connect.cc:1314(handle_one_connection)[0x55c5a62a31a4]
perfschema/pfs.cc:2203(pfs_spawn_thread)[0x55c5a6f3e159]
nptl/pthread_create.c:487(start_thread)[0x7fe28ff57fa3]
x86_64/clone.S:97(clone)[0x7fe28fb60eff]

Comment by Elena Stepanova [ 2023-08-24 ]

10.3 is EOL, not reproducible with the provided test case on higher versions.

The assertion apparently still fails as said in the comment above, but we'll need a new test case and better a new report for current versions.

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