[MDEV-27890] SIGSEGV in innobase_get_mysql_key_number_for_index and Assertion `table->magic_n == 76333786' failed in dict_table_get_first_index and InnoDB: Failing assertion: i > 0 and Assertion `!trx->check_foreigns' failed on INSERT Created: 2022-02-18  Updated: 2022-07-28  Resolved: 2022-07-26

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.7, 10.8, 10.9
Fix Version/s: 10.7.5

Type: Bug Priority: Major
Reporter: Roel Van de Paar Assignee: Thirunarayanan Balathandayuthapani
Resolution: Duplicate Votes: 0
Labels: not-10.2, not-10.3, not-10.4, not-10.5, not-10.6, regression

Issue Links:
Duplicate
duplicates MDEV-28242 Assertion `!check_foreigns' failed in... Closed
Problem/Incident
is caused by MDEV-24621 In bulk insert, pre-sort and build in... Closed
Relates
relates to MDEV-27953 Assertion `!check_unique_secondary' f... Closed
relates to MDEV-27858 Assertion `page_dir_get_n_heap(new_pa... Closed

 Description   

SET unique_checks=0, foreign_key_checks=0, autocommit=0;
CREATE TABLE t (c INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t VALUES (0);
INSERT INTO t VALUES (0);
DROP TABLE IF EXISTS t;
CREATE TABLE t (d INT KEY) ENGINE=InnoDB;  # Changing table name t to e in the last two queries yields the same result
INSERT INTO t SELECT s.SEQ FROM seq_1_to_128,seq_1_to_1024 s;

Leads to:

10.9.0 b5852ffbeebc3000982988383daeefb0549e058a (Optimized)

Core was generated by `/test/MD140222-mariadb-10.9.0-linux-x86_64-opt/bin/mysqld --no-defaults --core-'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  innobase_get_mysql_key_number_for_index (table=0x154ea0016ac8, 
    table=0x154ea0016ac8, index=0x154ea001da30, ib_table=0x154ea001ec40)
    at /test/10.9_opt/storage/innobase/handler/ha_innodb.cc:14424
[Current thread is 1 (Thread 0x154f297a0700 (LWP 3993205))]
(gdb) bt
#0  innobase_get_mysql_key_number_for_index (table=0x154ea0016ac8, table=0x154ea0016ac8, index=0x154ea001da30, ib_table=0x154ea001ec40) at /test/10.9_opt/storage/innobase/handler/ha_innodb.cc:14424
#1  ha_innobase::info_low (this=0x154ea004a1f0, flag=34, is_analyze=<optimized out>) at /test/10.9_opt/storage/innobase/handler/ha_innodb.cc:14904
#2  0x000056294268fbf0 in handler::get_dup_key (error=<optimized out>, this=0x154ea004a1f0) at /test/10.9_opt/sql/handler.cc:4783
#3  handler::get_dup_key (this=0x154ea004a1f0, error=<optimized out>) at /test/10.9_opt/sql/handler.cc:4770
#4  0x0000562942690205 in handler::print_error (this=0x154ea004a1f0, error=121, errflag=0) at /test/10.9_opt/sql/handler.cc:4342
#5  0x00005629423fe543 in write_record (thd=0x154ea0000c58, table=0x154ea0016ac8, info=info@entry=0x154ea004ed98, sink=0x0) at /test/10.9_opt/sql/sql_insert.cc:2201
#6  0x00005629423fecf3 in select_insert::send_data (this=0x154ea004ed48, values=<optimized out>) at /test/10.9_opt/sql/sql_insert.cc:4120
#7  0x000056294249d8dc in select_result_sink::send_data_with_check (u=<optimized out>, sent=<optimized out>, items=@0x154ea0011368: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x154ea0011668, last = 0x154ea0011668, elements = 1}, <No data fields>}, this=<optimized out>) at /test/10.9_opt/sql/sql_class.h:5612
#8  select_result_sink::send_data_with_check (sent=<optimized out>, u=<optimized out>, items=@0x154ea0011368: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x154ea0011668, last = 0x154ea0011668, elements = 1}, <No data fields>}, this=<optimized out>) at /test/10.9_opt/sql/sql_class.h:5602
#9  end_send (join=0x154ea004ee08, join_tab=0x154ea0050e18, end_of_records=<optimized out>) at /test/10.9_opt/sql/sql_select.cc:22331
#10 0x000056294258bf79 in JOIN_CACHE::generate_full_extensions (rec_ptr=0x154ea0055418 "\017", this=0x154ea00515d8) at /test/10.9_opt/sql/sql_join_cache.cc:2478
#11 JOIN_CACHE::generate_full_extensions (this=0x154ea00515d8, rec_ptr=0x154ea0055418 "\017") at /test/10.9_opt/sql/sql_join_cache.cc:2461
#12 0x000056294258c37e in JOIN_CACHE::join_matching_records (this=0x154ea00515d8, skip_last=false) at /test/10.9_opt/sql/sql_join_cache.cc:2370
#13 0x000056294258bbc1 in JOIN_CACHE::join_records (this=this@entry=0x154ea00515d8, skip_last=skip_last@entry=false) at /test/10.9_opt/sql/sql_join_cache.cc:2151
#14 0x000056294248724a in sub_select_cache (join=0x154ea004ee08, join_tab=0x154ea0050a68, end_of_records=<optimized out>) at /test/10.9_opt/sql/sql_select.cc:20869
#15 0x00005629424b4a4b in do_select (procedure=<optimized out>, join=0x154ea004ee08) at /test/10.9_opt/sql/sql_select.cc:20642
#16 JOIN::exec_inner (this=0x154ea004ee08) at /test/10.9_opt/sql/sql_select.cc:4749
#17 0x00005629424b4fb8 in JOIN::exec (this=this@entry=0x154ea004ee08) at /test/10.9_opt/sql/sql_select.cc:4527
#18 0x00005629424b30c1 in mysql_select (thd=0x154ea0000c58, tables=0x154ea00116c0, fields=@0x154ea0011368: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x154ea0011668, last = 0x154ea0011668, elements = 1}, <No data fields>}, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=<optimized out>, result=0x154ea004ed48, unit=0x154ea0004ea8, select_lex=0x154ea00110c8) at /test/10.9_opt/sql/sql_select.cc:5007
#19 0x00005629424b3877 in handle_select (thd=thd@entry=0x154ea0000c58, lex=lex@entry=0x154ea0004dd0, result=result@entry=0x154ea004ed48, setup_tables_done_option=setup_tables_done_option@entry=1073741824) at /test/10.9_opt/sql/sql_select.cc:543
#20 0x00005629424432c9 in mysql_execute_command (thd=0x154ea0000c58, is_called_from_prepared_stmt=<optimized out>) at /test/10.9_opt/sql/sql_parse.cc:4708
#21 0x000056294242f086 in mysql_parse (thd=0x154ea0000c58, rawbuf=<optimized out>, length=<optimized out>, parser_state=<optimized out>) at /test/10.9_opt/sql/sql_parse.cc:8027
#22 0x000056294243b235 in dispatch_command (command=COM_QUERY, thd=0x154ea0000c58, packet=<optimized out>, packet_length=<optimized out>, blocking=<optimized out>) at /test/10.9_opt/sql/sql_class.h:1362
#23 0x000056294243d427 in do_command (thd=0x154ea0000c58, blocking=blocking@entry=true) at /test/10.9_opt/sql/sql_parse.cc:1402
#24 0x000056294255cd77 in do_handle_one_connection (connect=<optimized out>, put_in_cache=true) at /test/10.9_opt/sql/sql_connect.cc:1418
#25 0x000056294255d0bd in handle_one_connection (arg=arg@entry=0x562946084848) at /test/10.9_opt/sql/sql_connect.cc:1312
#26 0x00005629428d67b1 in pfs_spawn_thread (arg=0x5629460199a8) at /test/10.9_opt/storage/perfschema/pfs.cc:2201
#27 0x0000154f50957609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#28 0x0000154f50545293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

10.9.0 b5852ffbeebc3000982988383daeefb0549e058a (Debug)

mysqld: /test/10.9_dbg/storage/innobase/include/dict0dict.inl:211: dict_index_t* dict_table_get_first_index(const dict_table_t*): Assertion `table->magic_n == 76333786' failed.

10.9.0 b5852ffbeebc3000982988383daeefb0549e058a (Debug)

Core was generated by `/test/MD140222-mariadb-10.9.0-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
Program terminated with signal SIGABRT, Aborted.
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
[Current thread is 1 (Thread 0x14afa8072700 (LWP 3994012))]
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x000014afb22d6859 in __GI_abort () at abort.c:79
#2  0x000014afb22d6729 in __assert_fail_base (fmt=0x14afb246c588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55ba14f4e22e "table->magic_n == 76333786", file=0x55ba14f51328 "/test/10.9_dbg/storage/innobase/include/dict0dict.inl", line=211, function=<optimized out>) at assert.c:92
#3  0x000014afb22e7f36 in __GI___assert_fail (assertion=assertion@entry=0x55ba14f4e22e "table->magic_n == 76333786", file=file@entry=0x55ba14f51328 "/test/10.9_dbg/storage/innobase/include/dict0dict.inl", line=line@entry=211, function=function@entry=0x55ba14f527e8 "dict_index_t* dict_table_get_first_index(const dict_table_t*)") at assert.c:101
#4  0x000055ba146d87b3 in dict_table_get_first_index (table=0x14aed0024238) at /test/10.9_dbg/storage/innobase/include/dict0dict.inl:211
#5  innobase_get_mysql_key_number_for_index (index=0x14aed00241e8, ib_table=0x14aed0021878, table=<optimized out>) at /test/10.9_dbg/storage/innobase/handler/ha_innodb.cc:14421
#6  ha_innobase::info_low (this=0x14aed0080e80, flag=<optimized out>, is_analyze=is_analyze@entry=false) at /test/10.9_dbg/storage/innobase/handler/ha_innodb.cc:14904
#7  0x000055ba146d8c82 in ha_innobase::info (this=<optimized out>, flag=<optimized out>) at /test/10.9_dbg/storage/innobase/handler/ha_innodb.cc:14935
#8  0x000055ba14332beb in handler::get_dup_key (this=this@entry=0x14aed0080e80, error=error@entry=121) at /test/10.9_dbg/sql/handler.cc:4783
#9  0x000055ba14332e92 in handler::print_error (this=0x14aed0080e80, error=121, errflag=0) at /test/10.9_dbg/sql/handler.cc:4342
#10 0x000055ba13fd05ba in write_record (thd=0x14aed0000db8, table=0x14aed00805a8, info=info@entry=0x14aed008b718, sink=<optimized out>) at /test/10.9_dbg/sql/sql_insert.cc:2201
#11 0x000055ba13fd07c9 in select_insert::send_data (this=0x14aed008b6c8, values=<optimized out>) at /test/10.9_dbg/sql/sql_insert.cc:4120
#12 0x000055ba1409889b in select_result_sink::send_data_with_check (sent=<optimized out>, u=<optimized out>, items=@0x14aed0014888: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14aed0014b88, last = 0x14aed0014b88, elements = 1}, <No data fields>}, this=<optimized out>) at /test/10.9_dbg/sql/sql_class.h:5612
#13 end_send (join=0x14aed008b788, join_tab=0x14aed008d798, end_of_records=<optimized out>) at /test/10.9_dbg/sql/sql_select.cc:22331
#14 0x000055ba141e316a in JOIN_CACHE::generate_full_extensions (this=this@entry=0x14aed008e0d8, rec_ptr=rec_ptr@entry=0x14aed0098518 "\017") at /test/10.9_dbg/sql/sql_join_cache.cc:2478
#15 0x000055ba141e3511 in JOIN_CACHE::join_matching_records (this=0x14aed008e0d8, skip_last=false) at /test/10.9_dbg/sql/sql_join_cache.cc:2370
#16 0x000055ba141e2b6a in JOIN_CACHE::join_records (this=this@entry=0x14aed008e0d8, skip_last=skip_last@entry=false) at /test/10.9_dbg/sql/sql_join_cache.cc:2151
#17 0x000055ba1407e900 in sub_select_cache (join=0x14aed008b788, join_tab=0x14aed008d3e8, end_of_records=<optimized out>) at /test/10.9_dbg/sql/sql_select.cc:20869
#18 0x000055ba1407e3c5 in sub_select (join=0x14aed008b788, join_tab=0x14aed008d038, end_of_records=<optimized out>) at /test/10.9_dbg/sql/sql_select.cc:21039
#19 0x000055ba140b634a in do_select (procedure=<optimized out>, join=0x14aed008b788) at /test/10.9_dbg/sql/sql_select.cc:20642
#20 JOIN::exec_inner (this=this@entry=0x14aed008b788) at /test/10.9_dbg/sql/sql_select.cc:4749
#21 0x000055ba140b68c0 in JOIN::exec (this=this@entry=0x14aed008b788) at /test/10.9_dbg/sql/sql_select.cc:4527
#22 0x000055ba140b48cf in mysql_select (thd=thd@entry=0x14aed0000db8, tables=0x14aed0014be0, fields=@0x14aed0014888: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14aed0014b88, last = 0x14aed0014b88, elements = 1}, <No data fields>}, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2202446596608, result=0x14aed008b6c8, unit=0x14aed00051c8, select_lex=0x14aed00145e8) at /test/10.9_dbg/sql/sql_select.cc:5007
#23 0x000055ba140b4b84 in handle_select (thd=thd@entry=0x14aed0000db8, lex=lex@entry=0x14aed00050f0, result=result@entry=0x14aed008b6c8, setup_tables_done_option=setup_tables_done_option@entry=1073741824) at /test/10.9_dbg/sql/sql_select.cc:543
#24 0x000055ba140230c4 in mysql_execute_command (thd=thd@entry=0x14aed0000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.9_dbg/sql/sql_parse.cc:4708
#25 0x000055ba1400d315 in mysql_parse (thd=thd@entry=0x14aed0000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14afa8071400) at /test/10.9_dbg/sql/sql_parse.cc:8027
#26 0x000055ba1401bfb1 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14aed0000db8, packet=packet@entry=0x14aed000b889 "INSERT INTO t SELECT s.SEQ FROM seq_1_to_128,seq_1_to_1024 s", packet_length=packet_length@entry=60, blocking=blocking@entry=true) at /test/10.9_dbg/sql/sql_class.h:1362
#27 0x000055ba1401f3f8 in do_command (thd=0x14aed0000db8, blocking=blocking@entry=true) at /test/10.9_dbg/sql/sql_parse.cc:1402
#28 0x000055ba14199fc4 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55ba169d74f8, put_in_cache=put_in_cache@entry=true) at /test/10.9_dbg/sql/sql_connect.cc:1418
#29 0x000055ba1419a5c9 in handle_one_connection (arg=arg@entry=0x55ba169d74f8) at /test/10.9_dbg/sql/sql_connect.cc:1312
#30 0x000055ba14620d67 in pfs_spawn_thread (arg=0x55ba168ea9a8) at /test/10.9_dbg/storage/perfschema/pfs.cc:2201
#31 0x000014afb27e5609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#32 0x000014afb23d3293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.7.2 (dbg), 10.7.2 (opt), 10.8.1 (dbg), 10.8.1 (opt), 10.9.0 (dbg), 10.9.0 (opt)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.2.42 (dbg), 10.2.42 (opt), 10.3.33 (dbg), 10.3.33 (opt), 10.4.23 (dbg), 10.4.23 (opt), 10.5.14 (dbg), 10.5.14 (opt), 10.6.6 (dbg), 10.6.6 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.36 (dbg), 5.7.36 (opt), 8.0.27 (dbg), 8.0.27 (opt)



 Comments   
Comment by Roel Van de Paar [ 2022-02-18 ]

Different assertion with this testcase:

SET sql_mode='', unique_checks=0, foreign_key_checks=0, autocommit=0;
CREATE TABLE t (PRIMARY KEY(a)) (SELECT 1 AS a) UNION ALL (SELECT 1 AS a);
CREATE TABLE t (c INT) ENGINE=InnoDB;
DROP TABLE IF EXISTS t;
CREATE TABLE t2 (c INT) ENGINE=InnoDB;
CREATE TABLE t (pk INT PRIMARY KEY);
INSERT INTO t SELECT b.SEQ FROM seq_1_to_128,seq_1_to_1024 b;

Leads to:

10.9.0 b5852ffbeebc3000982988383daeefb0549e058a (Debug)

InnoDB: Failing assertion: i > 0

10.9.0 b5852ffbeebc3000982988383daeefb0549e058a (Debug)

Core was generated by `/test/MD140222-mariadb-10.9.0-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
Program terminated with signal SIGABRT, Aborted.
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
[Current thread is 1 (Thread 0x153e900ca700 (LWP 3929768))]
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x0000153e98932859 in __GI_abort () at abort.c:79
#2  0x00005604e2b1ba63 in ut_dbg_assertion_failed (expr=expr@entry=0x5604e3147196 "i > 0", file=file@entry=0x5604e3149470 "/test/10.9_dbg/storage/innobase/handler/ha_innodb.cc", line=line@entry=14429) at /test/10.9_dbg/storage/innobase/ut/ut0dbg.cc:60
#3  0x00005604e28d0879 in innobase_get_mysql_key_number_for_index (index=0x153df40281d8, ib_table=0x153df4081288, table=<optimized out>) at /test/10.9_dbg/storage/innobase/handler/ha_innodb.cc:14429
#4  ha_innobase::info_low (this=0x153df4084eb0, flag=<optimized out>, is_analyze=is_analyze@entry=false) at /test/10.9_dbg/storage/innobase/handler/ha_innodb.cc:14904
#5  0x00005604e28d0c82 in ha_innobase::info (this=<optimized out>, flag=<optimized out>) at /test/10.9_dbg/storage/innobase/handler/ha_innodb.cc:14935
#6  0x00005604e252abeb in handler::get_dup_key (this=this@entry=0x153df4084eb0, error=error@entry=121) at /test/10.9_dbg/sql/handler.cc:4783
#7  0x00005604e252ae92 in handler::print_error (this=0x153df4084eb0, error=121, errflag=0) at /test/10.9_dbg/sql/handler.cc:4342
#8  0x00005604e21c85ba in write_record (thd=0x153df4000db8, table=0x153df407dd88, info=info@entry=0x153df408f508, sink=<optimized out>) at /test/10.9_dbg/sql/sql_insert.cc:2201
#9  0x00005604e21c87c9 in select_insert::send_data (this=0x153df408f4b8, values=<optimized out>) at /test/10.9_dbg/sql/sql_insert.cc:4120
#10 0x00005604e229089b in select_result_sink::send_data_with_check (sent=<optimized out>, u=<optimized out>, items=@0x153df4014888: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x153df4014b88, last = 0x153df4014b88, elements = 1}, <No data fields>}, this=<optimized out>) at /test/10.9_dbg/sql/sql_class.h:5612
#11 end_send (join=0x153df408f578, join_tab=0x153df4091588, end_of_records=<optimized out>) at /test/10.9_dbg/sql/sql_select.cc:22331
#12 0x00005604e23db16a in JOIN_CACHE::generate_full_extensions (this=this@entry=0x153df4091ec8, rec_ptr=rec_ptr@entry=0x153df409c238 "\017") at /test/10.9_dbg/sql/sql_join_cache.cc:2478
#13 0x00005604e23db511 in JOIN_CACHE::join_matching_records (this=0x153df4091ec8, skip_last=false) at /test/10.9_dbg/sql/sql_join_cache.cc:2370
#14 0x00005604e23dab6a in JOIN_CACHE::join_records (this=this@entry=0x153df4091ec8, skip_last=skip_last@entry=false) at /test/10.9_dbg/sql/sql_join_cache.cc:2151
#15 0x00005604e2276900 in sub_select_cache (join=0x153df408f578, join_tab=0x153df40911d8, end_of_records=<optimized out>) at /test/10.9_dbg/sql/sql_select.cc:20869
#16 0x00005604e22763c5 in sub_select (join=0x153df408f578, join_tab=0x153df4090e28, end_of_records=<optimized out>) at /test/10.9_dbg/sql/sql_select.cc:21039
#17 0x00005604e22ae34a in do_select (procedure=<optimized out>, join=0x153df408f578) at /test/10.9_dbg/sql/sql_select.cc:20642
#18 JOIN::exec_inner (this=this@entry=0x153df408f578) at /test/10.9_dbg/sql/sql_select.cc:4749
#19 0x00005604e22ae8c0 in JOIN::exec (this=this@entry=0x153df408f578) at /test/10.9_dbg/sql/sql_select.cc:4527
#20 0x00005604e22ac8cf in mysql_select (thd=thd@entry=0x153df4000db8, tables=0x153df4014be0, fields=@0x153df4014888: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x153df4014b88, last = 0x153df4014b88, elements = 1}, <No data fields>}, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2202446596608, result=0x153df408f4b8, unit=0x153df40051c8, select_lex=0x153df40145e8) at /test/10.9_dbg/sql/sql_select.cc:5007
#21 0x00005604e22acb84 in handle_select (thd=thd@entry=0x153df4000db8, lex=lex@entry=0x153df40050f0, result=result@entry=0x153df408f4b8, setup_tables_done_option=setup_tables_done_option@entry=1073741824) at /test/10.9_dbg/sql/sql_select.cc:543
#22 0x00005604e221b0c4 in mysql_execute_command (thd=thd@entry=0x153df4000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.9_dbg/sql/sql_parse.cc:4708
#23 0x00005604e2205315 in mysql_parse (thd=thd@entry=0x153df4000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x153e900c9400) at /test/10.9_dbg/sql/sql_parse.cc:8027
#24 0x00005604e2213fb1 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x153df4000db8, packet=packet@entry=0x153df400b889 "INSERT INTO t SELECT b.SEQ FROM seq_1_to_128,seq_1_to_1024 b", packet_length=packet_length@entry=60, blocking=blocking@entry=true) at /test/10.9_dbg/sql/sql_class.h:1362
#25 0x00005604e22173f8 in do_command (thd=0x153df4000db8, blocking=blocking@entry=true) at /test/10.9_dbg/sql/sql_parse.cc:1402
#26 0x00005604e2391fc4 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x5604e57987d8, put_in_cache=put_in_cache@entry=true) at /test/10.9_dbg/sql/sql_connect.cc:1418
#27 0x00005604e23925c9 in handle_one_connection (arg=arg@entry=0x5604e57987d8) at /test/10.9_dbg/sql/sql_connect.cc:1312
#28 0x00005604e2818d67 in pfs_spawn_thread (arg=0x5604e56da3e8) at /test/10.9_dbg/storage/perfschema/pfs.cc:2201
#29 0x0000153e98e41609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#30 0x0000153e98a2f293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.7.2 (dbg), 10.7.2 (opt), 10.8.1 (dbg), 10.8.1 (opt), 10.9.0 (dbg), 10.9.0 (opt)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.2.42 (dbg), 10.2.42 (opt), 10.3.33 (dbg), 10.3.33 (opt), 10.4.23 (dbg), 10.4.23 (opt), 10.5.14 (dbg), 10.5.14 (opt), 10.6.6 (dbg), 10.6.6 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.36 (dbg), 5.7.36 (opt), 8.0.27 (dbg), 8.0.27 (opt)

Comment by Roel Van de Paar [ 2022-02-18 ]

UniqueID's seen thus far

SIGSEGV|innobase_get_mysql_key_number_for_index|ha_innobase::info_low|handler::get_dup_key|handler::get_dup_key
table->magic_n == 76333786|SIGABRT|dict_table_get_first_index|innobase_get_mysql_key_number_for_index|ha_innobase::info_low|ha_innobase::info
i > 0|SIGABRT|ut_dbg_assertion_failed|innobase_get_mysql_key_number_for_index|ha_innobase::info_low|ha_innobase::info
i > 0|SIGABRT|ut_dbg_assertion_failed|innobase_get_mysql_key_number_for_index|ha_innobase::info_low|handler::get_dup_key
!trx->check_foreigns|SIGABRT|innodb_prepare_commit_versioned|ha_commit_trans|trans_commit_implicit|mysql_execute_command

Comment by Roel Van de Paar [ 2022-02-19 ]

Another stack/assertion

SET unique_checks=0,foreign_key_checks=0,autocommit=0;
CREATE TABLE t (c INT) PARTITION BY KEY(c);
INSERT INTO t VALUES (1),(1);
SET SESSION foreign_key_checks=1;
SHOW CREATE TABLE t;
CREATE TABLE t (d INT);

Leads to:

10.9.0 b5852ffbeebc3000982988383daeefb0549e058a (Debug)

mysqld: /test/10.9_dbg/storage/innobase/handler/ha_innodb.cc:3719: ulonglong innodb_prepare_commit_versioned(THD*, ulonglong*): Assertion `!trx->check_foreigns' failed.

10.9.0 b5852ffbeebc3000982988383daeefb0549e058a (Debug)

Core was generated by `/test/MD140222-mariadb-10.9.0-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
Program terminated with signal SIGABRT, Aborted.
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
[Current thread is 1 (Thread 0x1541801b0700 (LWP 3834098))]
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x0000154196e41859 in __GI_abort () at abort.c:79
#2  0x0000154196e41729 in __assert_fail_base (fmt=0x154196fd7588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x5562ae8f052b "!trx->check_foreigns", file=0x5562ae8f3470 "/test/10.9_dbg/storage/innobase/handler/ha_innodb.cc", line=3719, function=<optimized out>) at assert.c:92
#3  0x0000154196e52f36 in __GI___assert_fail (assertion=assertion@entry=0x5562ae8f052b "!trx->check_foreigns", file=file@entry=0x5562ae8f3470 "/test/10.9_dbg/storage/innobase/handler/ha_innodb.cc", line=line@entry=3719, function=function@entry=0x5562ae8f4100 "ulonglong innodb_prepare_commit_versioned(THD*, ulonglong*)") at assert.c:101
#4  0x00005562ae06185d in innodb_prepare_commit_versioned (thd=<optimized out>, trx_id=<optimized out>) at /test/10.9_dbg/storage/innobase/handler/ha_innodb.cc:3719
#5  0x00005562adce18b0 in ha_commit_trans (thd=thd@entry=0x154124000db8, all=all@entry=true) at /test/10.9_dbg/sql/handler.h:2022
#6  0x00005562adb5275a in trans_commit_implicit (thd=thd@entry=0x154124000db8) at /test/10.9_dbg/sql/transaction.cc:329
#7  0x00005562ad9c27db in mysql_execute_command (thd=thd@entry=0x154124000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.9_dbg/sql/sql_parse.cc:3746
#8  0x00005562ad9af315 in mysql_parse (thd=thd@entry=0x154124000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x1541801af400) at /test/10.9_dbg/sql/sql_parse.cc:8027
#9  0x00005562ad9bdfb1 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x154124000db8, packet=packet@entry=0x15412400b889 "CREATE TABLE t (d INT)", packet_length=packet_length@entry=22, blocking=blocking@entry=true) at /test/10.9_dbg/sql/sql_class.h:1362
#10 0x00005562ad9c13f8 in do_command (thd=0x154124000db8, blocking=blocking@entry=true) at /test/10.9_dbg/sql/sql_parse.cc:1402
#11 0x00005562adb3bfc4 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x5562b0e4e4c8, put_in_cache=put_in_cache@entry=true) at /test/10.9_dbg/sql/sql_connect.cc:1418
#12 0x00005562adb3c5c9 in handle_one_connection (arg=arg@entry=0x5562b0e4e4c8) at /test/10.9_dbg/sql/sql_connect.cc:1312
#13 0x00005562adfc2d67 in pfs_spawn_thread (arg=0x5562b0d61978) at /test/10.9_dbg/storage/perfschema/pfs.cc:2201
#14 0x0000154197350609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#15 0x0000154196f3e293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.7.2 (dbg), 10.8.1 (dbg), 10.9.0 (dbg)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.2.42 (dbg), 10.2.42 (opt), 10.3.33 (dbg), 10.3.33 (opt), 10.4.23 (dbg), 10.4.23 (opt), 10.5.14 (dbg), 10.5.14 (opt), 10.6.6 (dbg), 10.6.6 (opt), 10.7.2 (opt), 10.8.1 (opt), 10.9.0 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.36 (dbg), 5.7.36 (opt), 8.0.27 (dbg), 8.0.27 (opt)

Comment by Marko Mäkelä [ 2022-02-21 ]

I think that the KEY in the second CREATE TABLE statement is interpreted as PRIMARY KEY.

I do not necessarily agree that it is a critical bug if a user promises that there are no duplicates (SET unique_checks=0) and then goes ahead and inserts duplicates, and then something bad happens.

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