[MDEV-30489] Assertion `trx->bulk_insert' failed in innodb_prepare_commit_versioned on SET autocommit=ON Created: 2023-01-28  Updated: 2023-11-28

Status: Confirmed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.7, 10.8, 10.9, 10.10, 10.11, 11.0
Fix Version/s: 10.11

Type: Bug Priority: Major
Reporter: Roel Van de Paar Assignee: Thirunarayanan Balathandayuthapani
Resolution: Unresolved Votes: 0
Labels: regression-10.7

Issue Links:
Relates
relates to MDEV-24621 In bulk insert, pre-sort and build in... Closed

 Description   

SET unique_checks=0,foreign_key_checks=0;
CREATE TABLE t1 (c INT) ENGINE=InnoDB;
CREATE TABLE t2 (c INT) ENGINE=InnoDB;
SELECT 0 INTO OUTFILE 'a';
SET autocommit=0;
INSERT INTO t2 VALUES (0);
LOAD DATA INFILE 'a' INTO TABLE t1;
SET autocommit=ON;

Leads to:

11.0.1 b075191ba8598af6aff5549e6e19f6255aef258a (Debug)

mysqld: /test/11.0_dbg/storage/innobase/handler/ha_innodb.cc:3710: ulonglong innodb_prepare_commit_versioned(THD*, ulonglong*): Assertion `trx->bulk_insert' failed.

11.0.1 b075191ba8598af6aff5549e6e19f6255aef258a (Debug)

Core was generated by `/test/MD090123-mariadb-11.0.1-linux-x86_64-dbg/bin/mysqld --no-defaults --core-'.
Program terminated with signal SIGABRT, Aborted.
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=22825471546944)
    at ./nptl/pthread_kill.c:44
[Current thread is 1 (Thread 0x14c2781f9640 (LWP 4193991))]
(gdb) bt
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=22825471546944) at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (signo=6, threadid=22825471546944) at ./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=22825471546944, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3  0x000014c29c8b3476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4  0x000014c29c8997f3 in __GI_abort () at ./stdlib/abort.c:79
#5  0x000014c29c89971b in __assert_fail_base (fmt=0x14c29ca4e150 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x56471fe0dcd4 "trx->bulk_insert", file=0x56471fe110d0 "/test/11.0_dbg/storage/innobase/handler/ha_innodb.cc", line=3710, function=<optimized out>) at ./assert/assert.c:92
#6  0x000014c29c8aae96 in __GI___assert_fail (assertion=0x56471fe0dcd4 "trx->bulk_insert", file=0x56471fe110d0 "/test/11.0_dbg/storage/innobase/handler/ha_innodb.cc", line=3710, function=0x56471fe12148 "ulonglong innodb_prepare_commit_versioned(THD*, ulonglong*)") at ./assert/assert.c:101
#7  0x000056471f74ecd7 in innodb_prepare_commit_versioned (thd=<optimized out>, trx_id=<optimized out>) at /test/11.0_dbg/storage/innobase/handler/ha_innodb.cc:3710
#8  0x000056471f48ce08 in ha_commit_trans (thd=thd@entry=0x14c240000d58, all=all@entry=true) at /test/11.0_dbg/sql/handler.cc:1772
#9  0x000056471f320138 in trans_commit (thd=thd@entry=0x14c240000d58) at /test/11.0_dbg/sql/transaction.cc:266
#10 0x000056471f3230b2 in fix_autocommit (self=<optimized out>, thd=0x14c240000d58, type=<optimized out>) at /test/11.0_dbg/sql/sys_vars.cc:4494
#11 0x000056471f0de794 in sys_var::update (this=0x5647205bd3c0 <Sys_autocommit>, thd=0x14c240000d58, var=0x14c240013248) at /test/11.0_dbg/sql/set_var.cc:213
#12 0x000056471f0ded07 in set_var::update (this=<optimized out>, thd=<optimized out>) at /test/11.0_dbg/sql/set_var.cc:863
#13 0x000056471f0dff30 in sql_set_variables (thd=thd@entry=0x14c240000d58, var_list=var_list@entry=0x14c240005ee8, free=free@entry=true) at /test/11.0_dbg/sql/set_var.cc:745
#14 0x000056471f1ba543 in mysql_execute_command (thd=thd@entry=0x14c240000d58, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/11.0_dbg/sql/sql_parse.cc:5038
#15 0x000056471f1be934 in mysql_parse (thd=thd@entry=0x14c240000d58, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14c2781f82c0) at /test/11.0_dbg/sql/sql_parse.cc:8000
#16 0x000056471f1c0ac8 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14c240000d58, packet=packet@entry=0x14c24000ae09 "SET autocommit=ON", packet_length=packet_length@entry=17, blocking=blocking@entry=true) at /test/11.0_dbg/sql/sql_class.h:243
#17 0x000056471f1c2921 in do_command (thd=0x14c240000d58, blocking=blocking@entry=true) at /test/11.0_dbg/sql/sql_parse.cc:1407
#18 0x000056471f30c9ea in do_handle_one_connection (connect=<optimized out>, connect@entry=0x5647231a1748, put_in_cache=put_in_cache@entry=true) at /test/11.0_dbg/sql/sql_connect.cc:1416
#19 0x000056471f30cc4e in handle_one_connection (arg=0x5647231a1748) at /test/11.0_dbg/sql/sql_connect.cc:1318
#20 0x000014c29c905b43 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#21 0x000014c29c997a00 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

Bug confirmed present in:
MariaDB: 10.7.8 (dbg), 10.8.7 (dbg), 10.9.5 (dbg), 10.10.3 (dbg), 10.11.2 (dbg), 11.0.1 (dbg)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.3.38 (dbg), 10.3.38 (opt), 10.4.28 (dbg), 10.4.28 (opt), 10.5.19 (dbg), 10.5.19 (opt), 10.6.12 (dbg), 10.6.12 (opt), 10.7.8 (opt), 10.8.7 (opt), 10.9.5 (opt), 10.10.3 (opt), 10.11.2 (opt), 11.0.1 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.40 (dbg), 5.7.40 (opt), 8.0.31 (dbg), 8.0.31 (opt)



 Comments   
Comment by Roel Van de Paar [ 2023-02-24 ]

Secondary testcase with partially new stack. Same versions affected.

CREATE TABLE t (c INT) ENGINE=InnoDB;
INSERT INTO t VALUES (0);
SELECT * FROM t INTO OUTFILE 'a';
SET unique_checks=0,foreign_key_checks=0,autocommit=0;
CREATE TABLE t2 (c INT) ENGINE=InnoDB;
CREATE TABLE t3 (c INT) ENGINE=InnoDB;
INSERT INTO t2 VALUES (0),(0),(0);
LOAD DATA INFILE 'a' INTO TABLE t3;
CREATE TABLE t (c INT) ENGINE=InnoDB;

Leads to:

11.0.1 f2dc4d4c10ac36a73b5c1eb765352d3aee808d66 (Debug)

mariadbd: /test/11.0_dbg/storage/innobase/handler/ha_innodb.cc:3673: ulonglong innodb_prepare_commit_versioned(THD*, ulonglong*): Assertion `trx->bulk_insert' failed.

11.0.1 f2dc4d4c10ac36a73b5c1eb765352d3aee808d66 (Debug)

Core was generated by `/test/MD180223-mariadb-11.0.1-linux-x86_64-dbg/bin/mariadbd --no-defaults --cor'.
Program terminated with signal SIGABRT, Aborted.
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=22890634253888)
    at ./nptl/pthread_kill.c:44
[Current thread is 1 (Thread 0x14d1a41f9640 (LWP 911724))]
(gdb) bt
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=22890634253888) at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (signo=6, threadid=22890634253888) at ./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=22890634253888, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3  0x000014d1c90af476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4  0x000014d1c90957f3 in __GI_abort () at ./stdlib/abort.c:79
#5  0x000014d1c909571b in __assert_fail_base (fmt=0x14d1c924a150 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55dd3ff4a7d9 "trx->bulk_insert", file=0x55dd3ff4db30 "/test/11.0_dbg/storage/innobase/handler/ha_innodb.cc", line=3673, function=<optimized out>) at ./assert/assert.c:92
#6  0x000014d1c90a6e96 in __GI___assert_fail (assertion=0x55dd3ff4a7d9 "trx->bulk_insert", file=0x55dd3ff4db30 "/test/11.0_dbg/storage/innobase/handler/ha_innodb.cc", line=3673, function=0x55dd3ff4eb58 "ulonglong innodb_prepare_commit_versioned(THD*, ulonglong*)") at ./assert/assert.c:101
#7  0x000055dd3f7d7fe4 in innodb_prepare_commit_versioned (thd=<optimized out>, trx_id=<optimized out>) at /test/11.0_dbg/storage/innobase/handler/ha_innodb.cc:3673
#8  0x000055dd3f51c0c6 in ha_commit_trans (thd=thd@entry=0x14d158000d58, all=all@entry=true) at /test/11.0_dbg/sql/handler.cc:1812
#9  0x000055dd3f3ab3a2 in trans_commit_implicit (thd=thd@entry=0x14d158000d58) at /test/11.0_dbg/sql/transaction.cc:329
#10 0x000055dd3f23ae7a in mysql_execute_command (thd=thd@entry=0x14d158000d58, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/11.0_dbg/sql/sql_parse.cc:3751
#11 0x000055dd3f2427cf in mysql_parse (thd=thd@entry=0x14d158000d58, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x14d1a41f82c0) at /test/11.0_dbg/sql/sql_parse.cc:8002
#12 0x000055dd3f244963 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14d158000d58, packet=packet@entry=0x14d15800ae19 "CREATE TABLE t (c INT) ENGINE=InnoDB", packet_length=packet_length@entry=36, blocking=blocking@entry=true) at /test/11.0_dbg/sql/sql_class.h:242
#13 0x000055dd3f2467bc in do_command (thd=0x14d158000d58, blocking=blocking@entry=true) at /test/11.0_dbg/sql/sql_parse.cc:1407
#14 0x000055dd3f3976e2 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55dd42133528, put_in_cache=put_in_cache@entry=true) at /test/11.0_dbg/sql/sql_connect.cc:1416
#15 0x000055dd3f397941 in handle_one_connection (arg=0x55dd42133528) at /test/11.0_dbg/sql/sql_connect.cc:1318
#16 0x000014d1c9101b43 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#17 0x000014d1c9193a00 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

Bug confirmed present in:
MariaDB: 10.7.8 (dbg), 10.8.8 (dbg), 10.9.6 (dbg), 10.10.4 (dbg), 10.11.2 (dbg), 11.0.1 (dbg)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.3.38 (dbg), 10.3.38 (opt), 10.4.29 (dbg), 10.4.29 (opt), 10.5.20 (dbg), 10.5.20 (opt), 10.6.13 (dbg), 10.6.13 (opt), 10.7.8 (opt), 10.8.8 (opt), 10.9.6 (opt), 10.10.4 (opt), 10.11.2 (opt), 11.0.1 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.40 (dbg), 5.7.40 (opt), 8.0.31 (dbg), 8.0.31 (opt)

Comment by Roel Van de Paar [ 2023-02-24 ]

UniqueID's/Stacks seen thus far:

trx->bulk_insert|SIGABRT|innodb_prepare_commit_versioned|ha_commit_trans|trans_commit_implicit|mysql_execute_command
trx->bulk_insert|SIGABRT|innodb_prepare_commit_versioned|ha_commit_trans|trans_xa_commit|mysql_execute_command
trx->bulk_insert|SIGABRT|innodb_prepare_commit_versioned|ha_commit_trans|trans_commit|fix_autocommit

Comment by Roel Van de Paar [ 2023-03-14 ]

An additional testcase with some slightly different stacks, likely due to the XA.

SET unique_checks=0,foreign_key_checks=0;
CREATE TABLE t ENGINE=InnoDB AS SELECT 1 AS c;
SELECT * FROM t INTO OUTFILE 'a';
CREATE TABLE t2 (a INT) ENGINE=InnoDB;
XA BEGIN 'a';
CREATE TEMPORARY TABLE t (a INT) ENGINE=InnoDB;
INSERT INTO t2 VALUES (0);
LOAD DATA INFILE 'a' INTO TABLE t;
XA END 'a';
XA COMMIT 'a' ONE PHASE;

Leads to:

11.0.1 f2dc4d4c10ac36a73b5c1eb765352d3aee808d66 (Debug)

mariadbd: /test/11.0_dbg/storage/innobase/handler/ha_innodb.cc:3673: ulonglong innodb_prepare_commit_versioned(THD*, ulonglong*): Assertion `trx->bulk_insert' failed.

11.0.1 f2dc4d4c10ac36a73b5c1eb765352d3aee808d66 (Debug)

Core was generated by `/test/MD180223-mariadb-11.0.1-linux-x86_64-dbg/bin/mariadbd --no-defaults --cor'.
Program terminated with signal SIGABRT, Aborted.
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=22473752630848)
    at ./nptl/pthread_kill.c:44
[Current thread is 1 (Thread 0x1470940ad640 (LWP 976082))]
(gdb) bt
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=22473752630848) at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (signo=6, threadid=22473752630848) at ./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=22473752630848, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3  0x00001470ab94a476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4  0x00001470ab9307f3 in __GI_abort () at ./stdlib/abort.c:79
#5  0x00001470ab93071b in __assert_fail_base (fmt=0x1470abae5150 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x558456fde7d9 "trx->bulk_insert", file=0x558456fe1b30 "/test/11.0_dbg/storage/innobase/handler/ha_innodb.cc", line=3673, function=<optimized out>) at ./assert/assert.c:92
#6  0x00001470ab941e96 in __GI___assert_fail (assertion=0x558456fde7d9 "trx->bulk_insert", file=0x558456fe1b30 "/test/11.0_dbg/storage/innobase/handler/ha_innodb.cc", line=3673, function=0x558456fe2b58 "ulonglong innodb_prepare_commit_versioned(THD*, ulonglong*)") at ./assert/assert.c:101
#7  0x000055845686bfe4 in innodb_prepare_commit_versioned (thd=<optimized out>, trx_id=<optimized out>) at /test/11.0_dbg/storage/innobase/handler/ha_innodb.cc:3673
#8  0x00005584565b00c6 in ha_commit_trans (thd=thd@entry=0x147020000d58, all=all@entry=true) at /test/11.0_dbg/sql/handler.cc:1812
#9  0x000055845650d1e1 in trans_xa_commit (thd=thd@entry=0x147020000d58) at /test/11.0_dbg/sql/xa.cc:670
#10 0x00005584562d4929 in mysql_execute_command (thd=thd@entry=0x147020000d58, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/11.0_dbg/sql/sql_parse.cc:5869
#11 0x00005584562d67cf in mysql_parse (thd=thd@entry=0x147020000d58, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x1470940ac2c0) at /test/11.0_dbg/sql/sql_parse.cc:8002
#12 0x00005584562d8963 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x147020000d58, packet=packet@entry=0x14702000ae19 "XA COMMIT 'a' ONE PHASE", packet_length=packet_length@entry=23, blocking=blocking@entry=true) at /test/11.0_dbg/sql/sql_class.h:242
#13 0x00005584562da7bc in do_command (thd=0x147020000d58, blocking=blocking@entry=true) at /test/11.0_dbg/sql/sql_parse.cc:1407
#14 0x000055845642b6e2 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x558458ad9dc8, put_in_cache=put_in_cache@entry=true) at /test/11.0_dbg/sql/sql_connect.cc:1416
#15 0x000055845642b941 in handle_one_connection (arg=0x558458ad9dc8) at /test/11.0_dbg/sql/sql_connect.cc:1318
#16 0x00001470ab99cb43 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#17 0x00001470aba2ea00 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

Bug confirmed present in:
MariaDB: 10.7.8 (dbg), 10.8.8 (dbg), 10.9.6 (dbg), 10.10.4 (dbg), 10.11.2 (dbg), 11.0.1 (dbg)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.3.38 (dbg), 10.3.38 (opt), 10.4.29 (dbg), 10.4.29 (opt), 10.5.20 (dbg), 10.5.20 (opt), 10.6.13 (dbg), 10.6.13 (opt), 10.7.8 (opt), 10.8.8 (opt), 10.9.6 (opt), 10.10.4 (opt), 10.11.2 (opt), 11.0.1 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.40 (dbg), 5.7.40 (opt), 8.0.31 (dbg), 8.0.31 (opt)

Generated at Thu Feb 08 10:16:37 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.