[MDEV-17223] Assertion `thd->killed != 0' failed in ha_maria::enable_indexes Created: 2018-09-18  Updated: 2022-05-17  Resolved: 2022-02-16

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Alter Table, Storage Engine - Aria
Affects Version/s: 10.0, 10.1, 10.2, 10.3, 10.4, 10.5, 10.6
Fix Version/s: 10.3.35, 10.4.25, 10.5.16, 10.6.8, 10.7.4

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Michael Widenius
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-22500 Assertion `thd->killed != 0' failed i... Closed

 Description   

Note: the test is for reproducing purposes only! Don't put it into the regression suite, create a better one instead.

--let $run= 1000
--let $datadir= `SELECT @@datadir`
 
while ($run)
{
  --echo #########################
  --echo # $run run(s) left
 
  CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY) ENGINE=Aria;
  INSERT INTO t1 VALUES 
    (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),
    (NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),(NULL),
    (NULL),(NULL),(NULL),(NULL),(NULL);
 
  --connect (con1,localhost,root,,test)
  --send
    CREATE OR REPLACE TABLE t1 (c VARCHAR(1024) NOT NULL) ENGINE=Aria ROW_FORMAT FIXED;
 
  --connection default
  SELECT * FROM t1 INTO OUTFILE 'load_t1';
  LOAD DATA INFILE 'load_t1' REPLACE INTO TABLE t1;
  LOAD DATA INFILE 'load_t1' REPLACE INTO TABLE t1;
  LOAD DATA INFILE 'load_t1' REPLACE INTO TABLE t1;
  LOAD DATA INFILE 'load_t1' REPLACE INTO TABLE t1;
  --error 0,ER_DUP_ENTRY
  ALTER TABLE t1 ADD PRIMARY KEY(c(67));
  --connection con1
  --reap
  --disconnect con1
 
  --connection default
  DROP TABLE t1;
 
  --remove_file $datadir/test/load_t1
  --dec $run
}

10.0 b7944343dd3

mysqld: /data/src/10.0/storage/maria/ha_maria.cc:2025: virtual int ha_maria::enable_indexes(uint): Assertion `thd->killed != 0' failed.
180918  3:30:58 [ERROR] mysqld got signal 6 ;
 
#7  0x00007f7c66263ee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#8  0x00000000009ef1af in ha_maria::enable_indexes (this=0x7f7c5e883888, mode=2) at /data/src/10.0/storage/maria/ha_maria.cc:2025
#9  0x00000000009ef82f in ha_maria::end_bulk_insert (this=0x7f7c5e883888) at /data/src/10.0/storage/maria/ha_maria.cc:2219
#10 0x000000000063943e in handler::ha_end_bulk_insert (this=0x7f7c5e883888) at /data/src/10.0/sql/handler.h:2716
#11 0x0000000000709588 in copy_data_between_tables (thd=0x7f7c602a2070, from=0x7f7c5e8a2070, to=0x7f7c5ebbb070, create=..., ignore=false, order_num=0, order=0x0, copied=0x7f7c68332310, deleted=0x7f7c68332308, keys_onoff=Alter_info::LEAVE_AS_IS, alter_ctx=0x7f7c68331800) at /data/src/10.0/sql/sql_table.cc:9740
#12 0x0000000000707961 in mysql_alter_table (thd=0x7f7c602a2070, new_db=0x7f7c5e8fa760 "test", new_name=0x0, create_info=0x7f7c683324e0, table_list=0x7f7c5e8fa180, alter_info=0x7f7c68332450, order_num=0, order=0x0, ignore=false) at /data/src/10.0/sql/sql_table.cc:9150
#13 0x0000000000770139 in Sql_cmd_alter_table::execute (this=0x7f7c5e8fa830, thd=0x7f7c602a2070) at /data/src/10.0/sql/sql_alter.cc:312
#14 0x0000000000654f0e in mysql_execute_command (thd=0x7f7c602a2070) at /data/src/10.0/sql/sql_parse.cc:5118
#15 0x0000000000658564 in mysql_parse (thd=0x7f7c602a2070, rawbuf=0x7f7c5e8fa088 "ALTER TABLE t1 ADD PRIMARY KEY(c(67))", length=37, parser_state=0x7f7c68333640) at /data/src/10.0/sql/sql_parse.cc:6637
#16 0x000000000064ae84 in dispatch_command (command=COM_QUERY, thd=0x7f7c602a2070, packet=0x7f7c617e5071 "ALTER TABLE t1 ADD PRIMARY KEY(c(67))", packet_length=37) at /data/src/10.0/sql/sql_parse.cc:1300
#17 0x000000000064a184 in do_command (thd=0x7f7c602a2070) at /data/src/10.0/sql/sql_parse.cc:1003
#18 0x000000000076b88c in do_handle_one_connection (thd_arg=0x7f7c602a2070) at /data/src/10.0/sql/sql_connect.cc:1377
#19 0x000000000076b5fe in handle_one_connection (arg=0x7f7c602a2070) at /data/src/10.0/sql/sql_connect.cc:1292
#20 0x0000000000acdbd4 in pfs_spawn_thread (arg=0x7f7c601a2370) at /data/src/10.0/storage/perfschema/pfs.cc:1861
#21 0x00007f7c67f67494 in start_thread (arg=0x7f7c68334700) at pthread_create.c:333
#22 0x00007f7c6632093f in clone () from /lib/x86_64-linux-gnu/libc.so.6



 Comments   
Comment by Roel Van de Paar [ 2020-09-22 ]

SET SESSION aria_sort_buffer_size=10;
ALTER TABLE mysql.help_topic ENGINE=Aria;

Leads to:

10.5.6 2bac9782aa81ad386beaf00eb126ccf2d15031a1 (Debug)

mysqld: /test/10.5_dbg/storage/maria/ha_maria.cc:2030: virtual int ha_maria::enable_indexes(uint): Assertion `thd->killed != 0' 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 0x14ba308d1700 (LWP 2517688))]
(gdb) bt
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
#1  0x00005617dff4985a in my_write_core (sig=sig@entry=6) at /test/10.5_dbg/mysys/stacktrace.c:424
#2  0x00005617df7103a9 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  0x000014ba2eb678b1 in __GI_abort () at abort.c:79
#6  0x000014ba2eb5742a in __assert_fail_base (fmt=0x14ba2ecdea38 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x5617e02cb1d2 "thd->killed != 0", file=file@entry=0x5617e02cb5e0 "/test/10.5_dbg/storage/maria/ha_maria.cc", line=line@entry=2030, function=function@entry=0x5617e02cd660 <ha_maria::enable_indexes(unsigned int)::__PRETTY_FUNCTION__> "virtual int ha_maria::enable_indexes(uint)") at assert.c:92
#7  0x000014ba2eb574a2 in __GI___assert_fail (assertion=assertion@entry=0x5617e02cb1d2 "thd->killed != 0", file=file@entry=0x5617e02cb5e0 "/test/10.5_dbg/storage/maria/ha_maria.cc", line=line@entry=2030, function=function@entry=0x5617e02cd660 <ha_maria::enable_indexes(unsigned int)::__PRETTY_FUNCTION__> "virtual int ha_maria::enable_indexes(uint)") at assert.c:101
#8  0x00005617df969651 in ha_maria::enable_indexes (this=this@entry=0x14ba0cc3e4a0, mode=mode@entry=2) at /test/10.5_dbg/storage/maria/ha_maria.cc:2030
#9  0x00005617df96982b in ha_maria::end_bulk_insert (this=0x14ba0cc3e4a0) at /test/10.5_dbg/storage/maria/ha_maria.cc:2258
#10 0x00005617df71ea4a in handler::ha_end_bulk_insert (this=0x14ba0cc3e4a0) at /test/10.5_dbg/sql/handler.cc:4642
#11 0x00005617df5393ea in copy_data_between_tables (alter_ctx=0x14ba308ce630, keys_onoff=<optimized out>, deleted=<synthetic pointer>, copied=<synthetic pointer>, order=<optimized out>, order_num=0, ignore=false, create=@0x14ba308ce750: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x0, last = 0x0, elements = 0}, <No data fields>}, to=0x14ba0cc54888, from=0x14ba0cc52588, thd=0x14ba0cc15088) at /test/10.5_dbg/sql/sql_table.cc:11412
#12 mysql_alter_table (thd=thd@entry=0x14ba0cc15088, new_db=new_db@entry=0x14ba0cc19ac8, new_name=new_name@entry=0x14ba0cc19ed0, create_info=create_info@entry=0x14ba308cf220, table_list=<optimized out>, table_list@entry=0x14ba0cc741b8, alter_info=alter_info@entry=0x14ba308cf150, order_num=0, order=0x0, ignore=false, if_exists=false) at /test/10.5_dbg/sql/sql_table.cc:10716
#13 0x00005617df5bc636 in Sql_cmd_alter_table::execute (this=<optimized out>, thd=0x14ba0cc15088) at /test/10.5_dbg/sql/sql_alter.cc:534
#14 0x00005617df4629b0 in mysql_execute_command (thd=thd@entry=0x14ba0cc15088) at /test/10.5_dbg/sql/sql_parse.cc:5952
#15 0x00005617df46a324 in mysql_parse (thd=thd@entry=0x14ba0cc15088, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14ba308d0350, 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
#16 0x00005617df456d54 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14ba0cc15088, packet=packet@entry=0x14ba0cc67089 "", packet_length=packet_length@entry=40, 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
#17 0x00005617df45553e in do_command (thd=0x14ba0cc15088) at /test/10.5_dbg/sql/sql_parse.cc:1348
#18 0x00005617df5b4893 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x14ba0f8d4808, put_in_cache=put_in_cache@entry=true) at /test/10.5_dbg/sql/sql_connect.cc:1410
#19 0x00005617df5b4fb7 in handle_one_connection (arg=arg@entry=0x14ba0f8d4808) at /test/10.5_dbg/sql/sql_connect.cc:1312
#20 0x00005617dfa1f5c2 in pfs_spawn_thread (arg=0x14ba2d446508) at /test/10.5_dbg/storage/perfschema/pfs.cc:2201
#21 0x000014ba2f84a6db in start_thread (arg=0x14ba308d1700) at pthread_create.c:463
#22 0x000014ba2ec48a3f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

10.4.15 eae968f62d285de97ed607c87bc131cd863d5d03 (Debug)

mysqld: /test/10.4_dbg/storage/maria/ha_maria.cc:2016: virtual int ha_maria::enable_indexes(uint): Assertion `thd->killed != 0' failed.

10.4.15 eae968f62d285de97ed607c87bc131cd863d5d03 (Debug)

Core was generated by `/test/MD110820-mariadb-10.4.15-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 0x1486bc2d1700 (LWP 3489603))]
(gdb) bt
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:57
#1  0x0000558d1253c8a6 in my_write_core (sig=sig@entry=6) at /test/10.4_dbg/mysys/stacktrace.c:482
#2  0x0000558d11cb8cdc in handle_fatal_signal (sig=6) at /test/10.4_dbg/sql/signal_handler.cc:343
#3  <signal handler called>
#4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#5  0x00001486ba5688b1 in __GI_abort () at abort.c:79
#6  0x00001486ba55842a in __assert_fail_base (fmt=0x1486ba6dfa38 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x558d128fcd6e "thd->killed != 0", file=file@entry=0x558d128fd0c0 "/test/10.4_dbg/storage/maria/ha_maria.cc", line=line@entry=2016, function=function@entry=0x558d128ff0a0 <ha_maria::enable_indexes(unsigned int)::__PRETTY_FUNCTION__> "virtual int ha_maria::enable_indexes(uint)") at assert.c:92
#7  0x00001486ba5584a2 in __GI___assert_fail (assertion=assertion@entry=0x558d128fcd6e "thd->killed != 0", file=file@entry=0x558d128fd0c0 "/test/10.4_dbg/storage/maria/ha_maria.cc", line=line@entry=2016, function=function@entry=0x558d128ff0a0 <ha_maria::enable_indexes(unsigned int)::__PRETTY_FUNCTION__> "virtual int ha_maria::enable_indexes(uint)") at assert.c:101
#8  0x0000558d12341205 in ha_maria::enable_indexes (this=0x14869449c888, mode=<optimized out>) at /test/10.4_dbg/storage/maria/ha_maria.cc:2016
#9  0x0000558d1233a101 in ha_maria::end_bulk_insert (this=0x14869449c888) at /test/10.4_dbg/storage/maria/ha_maria.cc:2244
#10 0x0000558d11cc6594 in handler::ha_end_bulk_insert (this=0x14869449c888) at /test/10.4_dbg/sql/handler.cc:4415
#11 0x0000558d11ac7887 in copy_data_between_tables (thd=thd@entry=0x148694415070, from=from@entry=0x1486944bb070, to=to@entry=0x1486944d7070, create=@0x1486bc2cd8d8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14869446db78, last = 0x14869446e0f0, elements = 6}, <No data fields>}, ignore=ignore@entry=false, order_num=order_num@entry=0, order=0x0, copied=0x1486bc2cb1c0, deleted=0x1486bc2cb1e0, keys_onoff=Alter_info::LEAVE_AS_IS, alter_ctx=0x1486bc2ccd70) at /test/10.4_dbg/sql/sql_table.cc:10910
#12 0x0000558d11acf8e2 in mysql_alter_table (thd=thd@entry=0x148694415070, new_db=new_db@entry=0x148694419830, new_name=new_name@entry=0x148694419c38, create_info=create_info@entry=0x1486bc2cd950, table_list=<optimized out>, table_list@entry=0x14869446d1a0, alter_info=alter_info@entry=0x1486bc2cd890, order_num=0, order=0x0, ignore=false) at /test/10.4_dbg/sql/sql_table.cc:10262
#13 0x0000558d11b493df in Sql_cmd_alter_table::execute (this=0x14869446d868, thd=0x148694415070) at /test/10.4_dbg/sql/sql_alter.cc:514
#14 0x0000558d11a0da3d in mysql_execute_command (thd=thd@entry=0x148694415070) at /test/10.4_dbg/sql/sql_parse.cc:6098
#15 0x0000558d11a10090 in mysql_parse (thd=thd@entry=0x148694415070, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x1486bc2d0460, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.4_dbg/sql/sql_parse.cc:7896
#16 0x0000558d11a12920 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x148694415070, packet=packet@entry=0x148694457071 "", packet_length=packet_length@entry=40, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.4_dbg/sql/sql_parse.cc:1834
#17 0x0000558d11a1635b in do_command (thd=0x148694415070) at /test/10.4_dbg/sql/sql_parse.cc:1352
#18 0x0000558d11b428b6 in do_handle_one_connection (connect=connect@entry=0x1486b9035790) at /test/10.4_dbg/sql/sql_connect.cc:1412
#19 0x0000558d11b429d6 in handle_one_connection (arg=0x1486b9035790) at /test/10.4_dbg/sql/sql_connect.cc:1316
#20 0x00001486bb4cf6db in start_thread (arg=0x1486bc2d1700) at pthread_create.c:463
#21 0x00001486ba649a3f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

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

Bug confirmed not present in:
MariaDB: 10.1.47 (opt), 10.2.34 (opt), 10.3.25 (opt), 10.4.15 (opt), 10.5.6 (opt), 10.6.0 (opt)
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)

Unique ID's

thd->killed != 0|SIGABRT|ha_maria::enable_indexes|ha_maria::end_bulk_insert|handler::ha_end_bulk_insert|select_insert::prepare_eof 
thd->killed != 0|SIGABRT|ha_maria::enable_indexes|ha_maria::end_bulk_insert|handler::ha_end_bulk_insert|copy_data_between_tables

Comment by Michael Widenius [ 2022-02-16 ]

For MDEV-17223 the issue was an assert that didn't take into account that
we could get duplicate key errors when enabling unique indexes.
Fixed by not retrying repair in case of duplicate key error for this case, which avoids the assert.

Comment by Elena Stepanova [ 2022-05-17 ]

Adjusted fix version because this patch never went to 10.2.

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