[MDEV-25496] Assertion `trx->bulk_insert' failed in trx_undo_report_row_operation on INSERT Created: 2021-04-23  Updated: 2021-06-29  Resolved: 2021-06-29

Status: Closed
Project: MariaDB Server
Component/s: Partitioning, Storage Engine - InnoDB
Affects Version/s: 10.6
Fix Version/s: 10.6.3

Type: Bug Priority: Blocker
Reporter: Roel Van de Paar Assignee: Marko Mäkelä
Resolution: Fixed Votes: 0
Labels: not-10.2, not-10.3, not-10.4, not-10.5, regression

Issue Links:
Blocks
is blocked by MDEV-25534 Assertion `lock_table_has(trx, index-... Closed
Problem/Incident
is caused by MDEV-515 innodb bulk insert Closed
is caused by MDEV-24818 Concurrent use of InnoDB table is imp... Closed
Relates
relates to MDEV-25315 Assertion `ptr' failed in ut_align_do... Closed

 Description   

Discussed with marko. Further to MDEV-25315.

SET foreign_key_checks=0,unique_checks=0;
CREATE TABLE t (i INT) ENGINE=InnoDB PARTITION BY HASH (i) PARTITIONS 3;
INSERT INTO t VALUES (0);
INSERT INTO t VALUES (0x40),(0x41),(0x42),(0x43),(0x44),(0x45),(0x46),(0x47);

Leads to:

10.6.0 a3e3225cd3b816d47621e749e21a71b6a864a96a (Debug)

mysqld: /test/10.6_dbg/storage/innobase/trx/trx0rec.cc:2037: dberr_t trx_undo_report_row_operation(que_thr_t*, dict_index_t*, const dtuple_t*, const upd_t*, ulint, const rec_t*, const rec_offs*, roll_ptr_t*): Assertion `trx->bulk_insert' failed.

10.6.0 a3e3225cd3b816d47621e749e21a71b6a864a96a (Debug)

Core was generated by `/test/MD150421-mariadb-10.6.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 0x1539dc162700 (LWP 3412208))]
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00001539f11d1859 in __GI_abort () at abort.c:79
#2  0x00001539f11d1729 in __assert_fail_base (fmt=0x1539f1367588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x55a1988f4c55 "trx->bulk_insert", file=0x55a1988f4d70 "/test/10.6_dbg/storage/innobase/trx/trx0rec.cc", line=2037, function=<optimized out>) at assert.c:92
#3  0x00001539f11e2f36 in __GI___assert_fail (assertion=assertion@entry=0x55a1988f4c55 "trx->bulk_insert", file=file@entry=0x55a1988f4d70 "/test/10.6_dbg/storage/innobase/trx/trx0rec.cc", line=line@entry=2037, function=function@entry=0x55a1988f58f8 "dberr_t trx_undo_report_row_operation(que_thr_t*, dict_index_t*, const dtuple_t*, const upd_t*, ulint, const rec_t*, const rec_offs*, roll_ptr_t*)") at assert.c:101
#4  0x000055a1982985b7 in trx_undo_report_row_operation (thr=thr@entry=0x153998038a40, index=index@entry=0x15399802a5d8, clust_entry=clust_entry@entry=0x153998027a38, update=update@entry=0x0, cmpl_info=cmpl_info@entry=0, rec=rec@entry=0x0, offsets=0x0, roll_ptr=0x1539dc15f060) at /test/10.6_dbg/storage/innobase/trx/trx0rec.cc:2037
#5  0x000055a1982f4c9f in btr_cur_ins_lock_and_undo (flags=flags@entry=0, cursor=cursor@entry=0x1539dc15f570, entry=entry@entry=0x153998027a38, thr=thr@entry=0x153998038a40, mtr=mtr@entry=0x1539dc15fb20, inherit=inherit@entry=0x1539dc15f147) at /test/10.6_dbg/storage/innobase/btr/btr0cur.cc:3299
#6  0x000055a1982fb79f in btr_cur_optimistic_insert (flags=flags@entry=0, cursor=cursor@entry=0x1539dc15f570, offsets=offsets@entry=0x1539dc15f538, heap=heap@entry=0x1539dc15f530, entry=entry@entry=0x153998027a38, rec=rec@entry=0x1539dc15f548, big_rec=0x1539dc15f528, n_ext=<optimized out>, thr=0x153998038a40, mtr=0x1539dc15fb20) at /test/10.6_dbg/storage/innobase/btr/btr0cur.cc:3526
#7  0x000055a1981d476c in row_ins_clust_index_entry_low (flags=flags@entry=0, mode=<optimized out>, mode@entry=2, index=index@entry=0x15399802a5d8, n_uniq=n_uniq@entry=0, entry=entry@entry=0x153998027a38, n_ext=n_ext@entry=0, thr=<optimized out>) at /test/10.6_dbg/storage/innobase/row/row0ins.cc:2790
#8  0x000055a1981d6331 in row_ins_clust_index_entry (index=index@entry=0x15399802a5d8, entry=entry@entry=0x153998027a38, thr=thr@entry=0x153998038a40, n_ext=n_ext@entry=0) at /test/10.6_dbg/storage/innobase/row/row0ins.cc:3263
#9  0x000055a1981daf0a in row_ins_index_entry (thr=0x153998038a40, entry=0x153998027a38, index=0x15399802a5d8) at /test/10.6_dbg/storage/innobase/row/row0ins.cc:3388
#10 row_ins_index_entry_step (thr=0x153998038a40, node=0x153998038828) at /test/10.6_dbg/storage/innobase/row/row0ins.cc:3557
#11 row_ins (thr=0x153998038a40, node=0x153998038828) at /test/10.6_dbg/storage/innobase/row/row0ins.cc:3703
#12 row_ins_step (thr=thr@entry=0x153998038a40) at /test/10.6_dbg/storage/innobase/row/row0ins.cc:3845
#13 0x000055a1981ff8e0 in row_insert_for_mysql (mysql_rec=mysql_rec@entry=0x153998024d28 "\375C", prebuilt=0x153998038338, ins_mode=ROW_INS_NORMAL) at /test/10.6_dbg/storage/innobase/row/row0mysql.cc:1395
#14 0x000055a19808573a in ha_innobase::write_row (this=0x153998033350, record=0x153998024d28 "\375C") at /test/10.6_dbg/storage/innobase/handler/ha_innodb.cc:7424
#15 0x000055a197c90f0d in handler::ha_write_row (this=0x153998033350, buf=buf@entry=0x153998024d28 "\375C") at /test/10.6_dbg/sql/handler.cc:7156
#16 0x000055a197fb79d1 in ha_partition::write_row (this=0x153998032200, buf=0x153998024d28 "\375C") at /test/10.6_dbg/sql/ha_partition.cc:4475
#17 0x000055a197c90f0d in handler::ha_write_row (this=0x153998032200, buf=0x153998024d28 "\375C") at /test/10.6_dbg/sql/handler.cc:7156
#18 0x000055a19796abfd in write_record (thd=thd@entry=0x153998000db8, table=table@entry=0x15399801f838, info=info@entry=0x1539dc160d00, sink=sink@entry=0x0) at /test/10.6_dbg/sql/sql_insert.cc:2106
#19 0x000055a197976474 in mysql_insert (thd=thd@entry=0x153998000db8, table_list=0x153998013cf0, fields=@0x153998005e60: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x55a198f8c280 <end_of_list>, last = 0x153998005e60, elements = 0}, <No data fields>}, values_list=@0x153998005ea8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x153998014928, last = 0x153998014f10, elements = 8}, <No data fields>}, update_fields=@0x153998005e90: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x55a198f8c280 <end_of_list>, last = 0x153998005e90, elements = 0}, <No data fields>}, update_values=@0x153998005e78: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x55a198f8c280 <end_of_list>, last = 0x153998005e78, elements = 0}, <No data fields>}, duplic=DUP_ERROR, ignore=false, result=0x0) at /test/10.6_dbg/sql/sql_insert.cc:1099
#20 0x000055a1979bd1ac in mysql_execute_command (thd=thd@entry=0x153998000db8) at /test/10.6_dbg/sql/sql_parse.cc:4559
#21 0x000055a1979a7a06 in mysql_parse (thd=thd@entry=0x153998000db8, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x1539dc161410) at /test/10.6_dbg/sql/sql_parse.cc:8017
#22 0x000055a1979b67df in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x153998000db8, packet=packet@entry=0x15399800b369 "INSERT INTO t VALUES (0x40),(0x41),(0x42),(0x43),(0x44),(0x45),(0x46),(0x47)", packet_length=packet_length@entry=76, blocking=blocking@entry=true) at /test/10.6_dbg/sql/sql_class.h:1331
#23 0x000055a1979b9bd5 in do_command (thd=0x153998000db8, blocking=blocking@entry=true) at /test/10.6_dbg/sql/sql_parse.cc:1406
#24 0x000055a197b1377c in do_handle_one_connection (connect=<optimized out>, connect@entry=0x55a19ab7a6e8, put_in_cache=put_in_cache@entry=true) at /test/10.6_dbg/sql/sql_connect.cc:1410
#25 0x000055a197b13d81 in handle_one_connection (arg=arg@entry=0x55a19ab7a6e8) at /test/10.6_dbg/sql/sql_connect.cc:1312
#26 0x000055a197fc1a03 in pfs_spawn_thread (arg=0x55a19aa90aa8) at /test/10.6_dbg/storage/perfschema/pfs.cc:2201
#27 0x00001539f16df609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#28 0x00001539f12ce293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
10.6.0 (dbg)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.2.38 (dbg), 10.2.38 (opt), 10.3.29 (dbg), 10.3.29 (opt), 10.4.19 (dbg), 10.4.19 (opt), 10.5.10 (dbg), 10.5.10 (opt), 10.6.0 (opt)
MySQL: 5.5.62 (dbg), 5.5.62 (opt), 5.6.51 (dbg), 5.6.51 (opt), 5.7.33 (dbg), 5.7.33 (opt), 8.0.23 (dbg), 8.0.23 (opt)



 Comments   
Comment by Marko Mäkelä [ 2021-04-23 ]

Minimal test case:

--source include/have_innodb.inc
--source include/have_partition.inc
 
SET foreign_key_checks=0, unique_checks=0;
CREATE TABLE t (i INT) ENGINE=InnoDB PARTITION BY HASH (i) PARTITIONS 2;
INSERT INTO t VALUES (0);
INSERT INTO t VALUES (1),(0),(1);
DROP TABLE t;

The equivalent test case without partitioning will not crash:

--source include/have_innodb.inc
SET foreign_key_checks=0, unique_checks=0;
CREATE TABLE t0 (i INT) ENGINE=InnoDB;
CREATE TABLE t1 (i INT) ENGINE=InnoDB;
INSERT INTO t0 SET i=0;
BEGIN;
INSERT INTO t1 SET i=1;
INSERT INTO t0 SET i=0;
INSERT INTO t1 SET i=1;
COMMIT;
DROP TABLE t0,t1;

The problem is that our magic for detecting statement boundaries is not working correctly with partitioned tables:

10.6 1a647b700f6b72dc97211510a5d0c647d5d3d911

Thread 2 hit Hardware watchpoint 1: -location trx->bulk_insert
 
Old value = true
New value = false
0x0000559397b02f64 in row_get_prebuilt_insert_row (
    prebuilt=prebuilt@entry=0x7f9714036e48)
    at /mariadb/10.6-merge/storage/innobase/row/row0mysql.cc:1104
1104					prebuilt->trx->bulk_insert = false;
(rr) bt
#0  0x0000559397b02f64 in row_get_prebuilt_insert_row (
    prebuilt=prebuilt@entry=0x7f9714036e48)
    at /mariadb/10.6-merge/storage/innobase/row/row0mysql.cc:1104
#1  0x0000559397b03528 in row_insert_for_mysql (mysql_rec=<optimized out>, 
    mysql_rec@entry=0x7f97140163b0 <incomplete sequence \375>, 
    prebuilt=0x7f9714036e48, ins_mode=ROW_INS_NORMAL)
    at /mariadb/10.6-merge/storage/innobase/row/row0mysql.cc:1364
#2  0x0000559397991639 in ha_innobase::write_row (this=0x7f971402bff0, 
    record=0x7f97140163b0 <incomplete sequence \375>)
    at /mariadb/10.6-merge/storage/innobase/handler/ha_innodb.cc:7430
#3  0x000055939767040e in handler::ha_write_row (this=0x7f971402bff0, 
    buf=0x7f97140163b0 <incomplete sequence \375>)
    at /mariadb/10.6-merge/sql/handler.cc:7162
#4  0x00005593978e39c8 in ha_partition::write_row (this=0x7f971402b780, 
    buf=<optimized out>) at /mariadb/10.6-merge/sql/ha_partition.cc:4468

Comment by Roel Van de Paar [ 2021-04-27 ]

Few small observations. First, a slightly different testcase:

SET unique_checks=0,foreign_key_checks=0;
CREATE TABLE t (i INT AUTO_INCREMENT KEY) PARTITION BY HASH(i) PARTITIONS 4;
INSERT INTO t VALUES (0);
INSERT INTO t VALUES (2),(3),(4),(5),(6);

Will crash, whereas the following:

SET unique_checks=0,foreign_key_checks=0;
CREATE TABLE t (i INT AUTO_INCREMENT KEY) PARTITION BY HASH(i) PARTITIONS 4;
INSERT INTO t VALUES (0);
INSERT INTO t VALUES (1);

Will produce:

10.6.0 a3e3225cd3b816d47621e749e21a71b6a864a96a (Debug)

10.6.0-dbg>INSERT INTO t VALUES (1);
ERROR 1062 (23000): Duplicate entry '1' for key 'PRIMARY'

No idea why it would say dup key when the ID is fully unique.

Comment by Marko Mäkelä [ 2021-04-30 ]

My test still fails even after the MDEV-25534 fix:

10.6 fd8c68c7fe6b74fa8f83483c028c83638a2edbf2

SET foreign_key_checks=0, unique_checks=0;
CREATE TABLE t (i INT) ENGINE=InnoDB PARTITION BY HASH (i) PARTITIONS 2;
INSERT INTO t VALUES (0);
INSERT INTO t VALUES (1),(0),(1);
innodb.insert_into_empty-MDEV-25496 'innodb' [ fail ]
        Test ended at 2021-04-30 10:41:52
 
CURRENT_TEST: innodb.insert_into_empty-MDEV-25496
mysqltest: At line 7: query 'INSERT INTO t VALUES (1),(0),(1)' failed: 2013: Lost connection to server during query
mariadbd: /mariadb/10.6/storage/innobase/trx/trx0rec.cc:2037: dberr_t trx_undo_report_row_operation(que_thr_t *, dict_index_t *, const dtuple_t *, const upd_t *, ulint, const rec_t *, const rec_offs *, roll_ptr_t *): Assertion `trx->bulk_insert' failed.

Comment by Marko Mäkelä [ 2021-04-30 ]

nikitamalyavin investigated in MDEV-25534 that ha_innobase::start_stmt() is being called in some corner cases that I suggested.

But, during the execution of the following, neither ha_partition::start_stmt() nor ha_innopart::start_stmt() are invoked at all:

--source include/have_innodb.inc
--source include/have_partition.inc
SET foreign_key_checks=0, unique_checks=0;
CREATE TABLE t (i INT) ENGINE=InnoDB PARTITION BY HASH (i) PARTITIONS 2;
INSERT INTO t VALUES (0);
INSERT INTO t VALUES (1),(0),(1);
DROP TABLE t;

Also the equivalent test without partitioning does not invoke ha_innobase::start_stmt(), but the InnoDB workarounds for the missing call are effective in that case:

--source include/have_innodb.inc
SET foreign_key_checks=0, unique_checks=0;
CREATE TABLE t0 (i INT) ENGINE=InnoDB;
CREATE TABLE t1 (i INT) ENGINE=InnoDB;
INSERT INTO t0 SET i=0;
BEGIN;
INSERT INTO t1 SET i=1;
INSERT INTO t0 SET i=0;
INSERT INTO t1 SET i=1;
COMMIT;
DROP TABLE t0,t1;

Comment by Marko Mäkelä [ 2021-06-11 ]

The following code in InnoDB works around the lack of ha_innobase::start_stmt() calls. Other assignments to clear bulk_insert seem to be necessary even if the missing calls to ha_innobase::start_stmt() are added:

diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc
index 4adc279fb32..bb85e82cbb8 100644
--- a/storage/innobase/row/row0mysql.cc
+++ b/storage/innobase/row/row0mysql.cc
@@ -1051,13 +1051,6 @@ row_get_prebuilt_insert_row(
 		if (prebuilt->trx_id == table->def_trx_id
 		    && prebuilt->ins_node->entry_list.size()
 		    == UT_LIST_GET_LEN(table->indexes)) {
-
-			if (prebuilt->trx->bulk_insert
-			    && prebuilt->ins_node->trx_id
-			       != prebuilt->trx->id) {
-				prebuilt->trx->bulk_insert = false;
-			}
-
 			return(prebuilt->ins_node->row);
 		}
 

Comment by Nikita Malyavin [ 2021-06-14 ]

Though handler::start_stmt is not called, handler::ha_external_lock is, so `innobase_register_trx` is reached anyway.

Therefore the problem seems to be not in the transaction/statement boundary detection.

I am not proficient in bulk insertion mechanics to proceed further, so assigning back

Comment by Marko Mäkelä [ 2021-06-14 ]

nikitamalyavin, the calls to indicate statement boundaries are outside the InnoDB storage engine. I think that this must be fixed in the server core layer in a satisfactory way. I merely indicated where InnoDB includes one work-around for a missing call to ha_innobase::start_stmt(). If some code around versioned tables will have to be adjusted, I would like to point out that also that code is outside the InnoDB storage engine.

Comment by Nikita Malyavin [ 2021-06-14 ]

marko The boundaries are detected for both inserts in both plain CREATE TABLE and PARTITION one.
The gdb outputs indicate that even for plain CREATE TABLE trx->bulk_insert is set to false:
We can also note that ha_external_lock is called 4 times: 2 for each INSERT statement, indicating lock and unlock respectively:

Thread 2 hit Breakpoint 5, mysql_create_table (thd=0x555a2488ee68, create_table=0x555a248a10a8, create_info=0x7fb5002a2e50, alter_info=0x7fb5002a2d68) at ../sql/sql_table.cc:4602
4602	  TABLE_LIST *pos_in_locked_tables= 0;
(gdb) bt
#0  mysql_create_table (thd=0x555a2488ee68, create_table=0x555a248a10a8, create_info=0x7fb5002a2e50, alter_info=0x7fb5002a2d68) at ../sql/sql_table.cc:4602
#1  0x0000555a21357ca1 in Sql_cmd_create_table_like::execute (this=0x555a248a1048, thd=0x555a2488ee68) at ../sql/sql_table.cc:11770
#2  0x0000555a21228a67 in mysql_execute_command (thd=0x555a2488ee68) at ../sql/sql_parse.cc:5983
#3  0x0000555a21214821 in mysql_parse (thd=0x555a2488ee68, rawbuf=0x555a248a0fa0 "CREATE TABLE t (i INT) ENGINE=InnoDB", length=36, parser_state=0x7fb5002a52d8) at ../sql/sql_parse.cc:8016
#4  0x0000555a212110b2 in dispatch_command (command=COM_QUERY, thd=0x555a2488ee68, packet=0x555a24897ad9 "CREATE TABLE t (i INT) ENGINE=InnoDB", packet_length=36, blocking=true) at ../sql/sql_parse.cc:1897
#5  0x0000555a21215ad5 in do_command (thd=0x555a2488ee68, blocking=true) at ../sql/sql_parse.cc:1406
#6  0x0000555a2141df24 in do_handle_one_connection (connect=0x555a2484f5f8, put_in_cache=true) at ../sql/sql_connect.cc:1410
#7  0x0000555a2141dc5a in handle_one_connection (arg=0x555a2483d998) at ../sql/sql_connect.cc:1312
#8  0x0000555a21a51349 in pfs_spawn_thread (arg=0x555a24797f98) at ../storage/perfschema/pfs.cc:2201
#9  0x00007fb50ea03299 in start_thread () from /usr/lib/libpthread.so.0
#10 0x00007fb50e72c053 in clone () from /usr/lib/libc.so.6
 
 
(gdb) n
4603	  MDL_ticket *mdl_ticket= 0;
(gdb) c
Continuing.
 
Thread 2 hit Breakpoint 2, mysql_insert (thd=0x555a2488ee68, table_list=0x555a248a1078, fields=..., values_list=..., update_fields=..., update_values=..., duplic=DUP_ERROR, ignore=false, result=0x0) at ../sql/sql_insert.cc:711
711	  Name_resolution_context_state ctx_state;
(gdb) c
Continuing.
 
Thread 2 hit Breakpoint 3, ha_innobase::external_lock (this=0x555a24996ff0, thd=0x555a2488ee68, lock_type=1) at ../storage/innobase/handler/ha_innodb.cc:15483
15483		switch (sql_command) {
(gdb) bt
#0  ha_innobase::external_lock (this=0x555a24996ff0, thd=0x555a2488ee68, lock_type=1) at ../storage/innobase/handler/ha_innodb.cc:15483
#1  0x0000555a21641d0a in handler::ha_external_lock (this=0x555a24996ff0, thd=0x555a2488ee68, lock_type=1) at ../sql/handler.cc:6770
#2  0x0000555a217e6fdb in lock_external (thd=0x555a2488ee68, tables=0x555a248a2698, count=1) at ../sql/lock.cc:393
#3  0x0000555a217e6aee in mysql_lock_tables (thd=0x555a2488ee68, sql_lock=0x555a248a2678, flags=0) at ../sql/lock.cc:338
#4  0x0000555a217e5b1d in mysql_lock_tables (thd=0x555a2488ee68, tables=0x555a248a2670, count=1, flags=0) at ../sql/lock.cc:301
#5  0x0000555a2114a57c in lock_tables (thd=0x555a2488ee68, tables=0x555a248a1078, count=1, flags=0) at ../sql/sql_base.cc:5538
#6  0x0000555a2114bcb4 in open_and_lock_tables (thd=0x555a2488ee68, options=..., tables=0x555a248a1078, derived=true, flags=0, prelocking_strategy=0x7fb5002a2ae0) at ../sql/sql_base.cc:5250
#7  0x0000555a210edc70 in open_and_lock_tables (thd=0x555a2488ee68, tables=0x555a248a1078, derived=true, flags=0) at ../sql/sql_base.h:509
#8  0x0000555a211b51b8 in mysql_insert (thd=0x555a2488ee68, table_list=0x555a248a1078, fields=..., values_list=..., update_fields=..., update_values=..., duplic=DUP_ERROR, ignore=false, result=0x0) at ../sql/sql_insert.cc:756
#9  0x0000555a21221179 in mysql_execute_command (thd=0x555a2488ee68) at ../sql/sql_parse.cc:4556
#10 0x0000555a21214821 in mysql_parse (thd=0x555a2488ee68, rawbuf=0x555a248a0fa0 "INSERT INTO t VALUES (0)", length=24, parser_state=0x7fb5002a52d8) at ../sql/sql_parse.cc:8016
#11 0x0000555a212110b2 in dispatch_command (command=COM_QUERY, thd=0x555a2488ee68, packet=0x555a24897ad9 "INSERT INTO t VALUES (0)", packet_length=24, blocking=true) at ../sql/sql_parse.cc:1897
#12 0x0000555a21215ad5 in do_command (thd=0x555a2488ee68, blocking=true) at ../sql/sql_parse.cc:1406
#13 0x0000555a2141df24 in do_handle_one_connection (connect=0x555a2484f5f8, put_in_cache=true) at ../sql/sql_connect.cc:1410
#14 0x0000555a2141dc5a in handle_one_connection (arg=0x555a2483d998) at ../sql/sql_connect.cc:1312
#15 0x0000555a21a51349 in pfs_spawn_thread (arg=0x555a24797f98) at ../storage/perfschema/pfs.cc:2201
#16 0x00007fb50ea03299 in start_thread () from /usr/lib/libpthread.so.0
#17 0x00007fb50e72c053 in clone () from /usr/lib/libc.so.6
(gdb) p trx->bulk_insert
$1 = false
(gdb) c
Continuing.
 
Thread 2 hit Breakpoint 3, ha_innobase::external_lock (this=0x555a24996ff0, thd=0x555a2488ee68, lock_type=2) at ../storage/innobase/handler/ha_innodb.cc:15483
15483		switch (sql_command) {
(gdb) bt
#0  ha_innobase::external_lock (this=0x555a24996ff0, thd=0x555a2488ee68, lock_type=2) at ../storage/innobase/handler/ha_innodb.cc:15483
#1  0x0000555a21641d0a in handler::ha_external_lock (this=0x555a24996ff0, thd=0x555a2488ee68, lock_type=2) at ../sql/handler.cc:6770
#2  0x0000555a2135d712 in handler::ha_external_unlock (this=0x555a24996ff0, thd=0x555a2488ee68) at ../sql/handler.h:3532
#3  0x0000555a217e71a1 in unlock_external (thd=0x555a2488ee68, table=0x555a248a2698, count=1) at ../sql/lock.cc:727
#4  0x0000555a217e7346 in mysql_unlock_tables (thd=0x555a2488ee68, sql_lock=0x555a248a2678, free_lock=false) at ../sql/lock.cc:432
#5  0x0000555a217e75ee in mysql_unlock_tables (thd=0x555a2488ee68, sql_lock=0x555a248a2678) at ../sql/lock.cc:415
#6  0x0000555a2114028f in close_thread_tables (thd=0x555a2488ee68) at ../sql/sql_base.cc:913
#7  0x0000555a21228fee in mysql_execute_command (thd=0x555a2488ee68) at ../sql/sql_parse.cc:6049
#8  0x0000555a21214821 in mysql_parse (thd=0x555a2488ee68, rawbuf=0x555a248a0fa0 "INSERT INTO t VALUES (0)", length=24, parser_state=0x7fb5002a52d8) at ../sql/sql_parse.cc:8016
#9  0x0000555a212110b2 in dispatch_command (command=COM_QUERY, thd=0x555a2488ee68, packet=0x555a24897ad9 "INSERT INTO t VALUES (0)", packet_length=24, blocking=true) at ../sql/sql_parse.cc:1897
#10 0x0000555a21215ad5 in do_command (thd=0x555a2488ee68, blocking=true) at ../sql/sql_parse.cc:1406
#11 0x0000555a2141df24 in do_handle_one_connection (connect=0x555a2484f5f8, put_in_cache=true) at ../sql/sql_connect.cc:1410
#12 0x0000555a2141dc5a in handle_one_connection (arg=0x555a2483d998) at ../sql/sql_connect.cc:1312
#13 0x0000555a21a51349 in pfs_spawn_thread (arg=0x555a24797f98) at ../storage/perfschema/pfs.cc:2201
#14 0x00007fb50ea03299 in start_thread () from /usr/lib/libpthread.so.0
#15 0x00007fb50e72c053 in clone () from /usr/lib/libc.so.6
(gdb) p trx->bulk_insert
$2 = false
(gdb) c
Continuing.
 
Thread 2 hit Breakpoint 2, mysql_insert (thd=0x555a2488ee68, table_list=0x555a248a1088, fields=..., values_list=..., update_fields=..., update_values=..., duplic=DUP_ERROR, ignore=false, result=0x0) at ../sql/sql_insert.cc:711
711	  Name_resolution_context_state ctx_state;
(gdb) c
Continuing.
 
Thread 2 hit Breakpoint 3, ha_innobase::external_lock (this=0x555a24996ff0, thd=0x555a2488ee68, lock_type=1) at ../storage/innobase/handler/ha_innodb.cc:15483
15483		switch (sql_command) {
(gdb) bt
#0  ha_innobase::external_lock (this=0x555a24996ff0, thd=0x555a2488ee68, lock_type=1) at ../storage/innobase/handler/ha_innodb.cc:15483
#1  0x0000555a21641d0a in handler::ha_external_lock (this=0x555a24996ff0, thd=0x555a2488ee68, lock_type=1) at ../sql/handler.cc:6770
#2  0x0000555a217e6fdb in lock_external (thd=0x555a2488ee68, tables=0x555a248a2818, count=1) at ../sql/lock.cc:393
#3  0x0000555a217e6aee in mysql_lock_tables (thd=0x555a2488ee68, sql_lock=0x555a248a27f8, flags=0) at ../sql/lock.cc:338
#4  0x0000555a217e5b1d in mysql_lock_tables (thd=0x555a2488ee68, tables=0x555a248a27f0, count=1, flags=0) at ../sql/lock.cc:301
#5  0x0000555a2114a57c in lock_tables (thd=0x555a2488ee68, tables=0x555a248a1088, count=1, flags=0) at ../sql/sql_base.cc:5538
#6  0x0000555a2114bcb4 in open_and_lock_tables (thd=0x555a2488ee68, options=..., tables=0x555a248a1088, derived=true, flags=0, prelocking_strategy=0x7fb5002a2ae0) at ../sql/sql_base.cc:5250
#7  0x0000555a210edc70 in open_and_lock_tables (thd=0x555a2488ee68, tables=0x555a248a1088, derived=true, flags=0) at ../sql/sql_base.h:509
#8  0x0000555a211b51b8 in mysql_insert (thd=0x555a2488ee68, table_list=0x555a248a1088, fields=..., values_list=..., update_fields=..., update_values=..., duplic=DUP_ERROR, ignore=false, result=0x0) at ../sql/sql_insert.cc:756
#9  0x0000555a21221179 in mysql_execute_command (thd=0x555a2488ee68) at ../sql/sql_parse.cc:4556
#10 0x0000555a21214821 in mysql_parse (thd=0x555a2488ee68, rawbuf=0x555a248a0fa0 "INSERT INTO t VALUES (1),(0),(1)", length=32, parser_state=0x7fb5002a52d8) at ../sql/sql_parse.cc:8016
#11 0x0000555a212110b2 in dispatch_command (command=COM_QUERY, thd=0x555a2488ee68, packet=0x555a24897ad9 "INSERT INTO t VALUES (1),(0),(1)", packet_length=32, blocking=true) at ../sql/sql_parse.cc:1897
#12 0x0000555a21215ad5 in do_command (thd=0x555a2488ee68, blocking=true) at ../sql/sql_parse.cc:1406
#13 0x0000555a2141df24 in do_handle_one_connection (connect=0x555a2484f5f8, put_in_cache=true) at ../sql/sql_connect.cc:1410
#14 0x0000555a2141dc5a in handle_one_connection (arg=0x555a2483d998) at ../sql/sql_connect.cc:1312
#15 0x0000555a21a51349 in pfs_spawn_thread (arg=0x555a24797f98) at ../storage/perfschema/pfs.cc:2201
#16 0x00007fb50ea03299 in start_thread () from /usr/lib/libpthread.so.0
#17 0x00007fb50e72c053 in clone () from /usr/lib/libc.so.6
(gdb) p trx->bulk_insert
$3 = false
(gdb) c
Continuing.
 
Thread 2 hit Breakpoint 3, ha_innobase::external_lock (this=0x555a24996ff0, thd=0x555a2488ee68, lock_type=2) at ../storage/innobase/handler/ha_innodb.cc:15483
15483		switch (sql_command) {
(gdb) p trx->bulk_insert
$4 = false
(gdb) bt
#0  ha_innobase::external_lock (this=0x555a24996ff0, thd=0x555a2488ee68, lock_type=2) at ../storage/innobase/handler/ha_innodb.cc:15483
#1  0x0000555a21641d0a in handler::ha_external_lock (this=0x555a24996ff0, thd=0x555a2488ee68, lock_type=2) at ../sql/handler.cc:6770
#2  0x0000555a2135d712 in handler::ha_external_unlock (this=0x555a24996ff0, thd=0x555a2488ee68) at ../sql/handler.h:3532
#3  0x0000555a217e71a1 in unlock_external (thd=0x555a2488ee68, table=0x555a248a2818, count=1) at ../sql/lock.cc:727
#4  0x0000555a217e7346 in mysql_unlock_tables (thd=0x555a2488ee68, sql_lock=0x555a248a27f8, free_lock=false) at ../sql/lock.cc:432
#5  0x0000555a217e75ee in mysql_unlock_tables (thd=0x555a2488ee68, sql_lock=0x555a248a27f8) at ../sql/lock.cc:415
#6  0x0000555a2114028f in close_thread_tables (thd=0x555a2488ee68) at ../sql/sql_base.cc:913
#7  0x0000555a21228fee in mysql_execute_command (thd=0x555a2488ee68) at ../sql/sql_parse.cc:6049
#8  0x0000555a21214821 in mysql_parse (thd=0x555a2488ee68, rawbuf=0x555a248a0fa0 "INSERT INTO t VALUES (1),(0),(1)", length=32, parser_state=0x7fb5002a52d8) at ../sql/sql_parse.cc:8016
#9  0x0000555a212110b2 in dispatch_command (command=COM_QUERY, thd=0x555a2488ee68, packet=0x555a24897ad9 "INSERT INTO t VALUES (1),(0),(1)", packet_length=32, blocking=true) at ../sql/sql_parse.cc:1897
#10 0x0000555a21215ad5 in do_command (thd=0x555a2488ee68, blocking=true) at ../sql/sql_parse.cc:1406
#11 0x0000555a2141df24 in do_handle_one_connection (connect=0x555a2484f5f8, put_in_cache=true) at ../sql/sql_connect.cc:1410
#12 0x0000555a2141dc5a in handle_one_connection (arg=0x555a2483d998) at ../sql/sql_connect.cc:1312
#13 0x0000555a21a51349 in pfs_spawn_thread (arg=0x555a24797f98) at ../storage/perfschema/pfs.cc:2201
#14 0x00007fb50ea03299 in start_thread () from /usr/lib/libpthread.so.0
#15 0x00007fb50e72c053 in clone () from /usr/lib/libc.so.6

The PARTITION case outputs look the same. The difference is that ha_innobase:::external_lock is called 4 times for the statement, one lock/unlock pair for each partition. The second statement aborts:

Thread 2 hit Breakpoint 6, mysql_create_table (thd=0x55892a79ae68, create_table=0x55892a7ad0e8, create_info=0x7f00cc059e50, alter_info=0x7f00cc059d68) at ../sql/sql_table.cc:4602
4602	  TABLE_LIST *pos_in_locked_tables= 0;
(gdb) p thd->query()
$1 = 0x55892a7acfa0 "CREATE TABLE t (i INT) ENGINE=InnoDB PARTITION BY HASH (i) PARTITIONS 2"
(gdb) c
Continuing.
 
Thread 2 hit Breakpoint 2, mysql_insert (thd=0x55892a79ae68, table_list=0x55892a7ad078, fields=..., values_list=..., update_fields=..., update_values=..., duplic=DUP_ERROR, ignore=false, result=0x0) at ../sql/sql_insert.cc:711
711	  Name_resolution_context_state ctx_state;
(gdb) p thd->query()
$2 = 0x55892a7acfa0 "INSERT INTO t VALUES (0)"
(gdb) c
Continuing.
 
Thread 2 hit Breakpoint 3, ha_innobase::external_lock (this=0x55892a9acd00, thd=0x55892a79ae68, lock_type=1) at ../storage/innobase/handler/ha_innodb.cc:15483
15483		switch (sql_command) {
(gdb) bt
#0  ha_innobase::external_lock (this=0x55892a9acd00, thd=0x55892a79ae68, lock_type=1) at ../storage/innobase/handler/ha_innodb.cc:15483
#1  0x00005589270e0d72 in handler::ha_external_lock (this=0x55892a9acd00, thd=0x55892a79ae68, lock_type=1) at ../sql/handler.cc:6770
#2  0x00005589274cf253 in ha_partition::external_lock (this=0x55892a9ac490, thd=0x55892a79ae68, lock_type=1) at ../sql/ha_partition.cc:4072
#3  0x00005589270e0d0a in handler::ha_external_lock (this=0x55892a9ac490, thd=0x55892a79ae68, lock_type=1) at ../sql/handler.cc:6770
#4  0x0000558927285fdb in lock_external (thd=0x55892a79ae68, tables=0x55892a7ae698, count=1) at ../sql/lock.cc:393
#5  0x0000558927285aee in mysql_lock_tables (thd=0x55892a79ae68, sql_lock=0x55892a7ae678, flags=0) at ../sql/lock.cc:338
#6  0x0000558927284b1d in mysql_lock_tables (thd=0x55892a79ae68, tables=0x55892a7ae670, count=1, flags=0) at ../sql/lock.cc:301
#7  0x0000558926be957c in lock_tables (thd=0x55892a79ae68, tables=0x55892a7ad078, count=1, flags=0) at ../sql/sql_base.cc:5538
#8  0x0000558926beacb4 in open_and_lock_tables (thd=0x55892a79ae68, options=..., tables=0x55892a7ad078, derived=true, flags=0, prelocking_strategy=0x7f00cc059ae0) at ../sql/sql_base.cc:5250
#9  0x0000558926b8cc70 in open_and_lock_tables (thd=0x55892a79ae68, tables=0x55892a7ad078, derived=true, flags=0) at ../sql/sql_base.h:509
#10 0x0000558926c541b8 in mysql_insert (thd=0x55892a79ae68, table_list=0x55892a7ad078, fields=..., values_list=..., update_fields=..., update_values=..., duplic=DUP_ERROR, ignore=false, result=0x0) at ../sql/sql_insert.cc:756
#11 0x0000558926cc0179 in mysql_execute_command (thd=0x55892a79ae68) at ../sql/sql_parse.cc:4556
#12 0x0000558926cb3821 in mysql_parse (thd=0x55892a79ae68, rawbuf=0x55892a7acfa0 "INSERT INTO t VALUES (0)", length=24, parser_state=0x7f00cc05c2d8) at ../sql/sql_parse.cc:8016
#13 0x0000558926cb00b2 in dispatch_command (command=COM_QUERY, thd=0x55892a79ae68, packet=0x55892a7a3ad9 "INSERT INTO t VALUES (0)", packet_length=24, blocking=true) at ../sql/sql_parse.cc:1897
#14 0x0000558926cb4ad5 in do_command (thd=0x55892a79ae68, blocking=true) at ../sql/sql_parse.cc:1406
#15 0x0000558926ebcf24 in do_handle_one_connection (connect=0x55892a75b5f8, put_in_cache=true) at ../sql/sql_connect.cc:1410
#16 0x0000558926ebcc5a in handle_one_connection (arg=0x55892a749998) at ../sql/sql_connect.cc:1312
#17 0x00005589274f0349 in pfs_spawn_thread (arg=0x55892a6a3f98) at ../storage/perfschema/pfs.cc:2201
#18 0x00007f00d479a299 in start_thread () from /usr/lib/libpthread.so.0
#19 0x00007f00d44c3053 in clone () from /usr/lib/libc.so.6
 
 
(gdb) p trx->bulk_insert
$3 = false
(gdb) c
Continuing.
 
Thread 2 hit Breakpoint 3, ha_innobase::external_lock (this=0x55892a9ad4e0, thd=0x55892a79ae68, lock_type=1) at ../storage/innobase/handler/ha_innodb.cc:15483
15483		switch (sql_command) {
(gdb) bt
#0  ha_innobase::external_lock (this=0x55892a9ad4e0, thd=0x55892a79ae68, lock_type=1) at ../storage/innobase/handler/ha_innodb.cc:15483
#1  0x00005589270e0d72 in handler::ha_external_lock (this=0x55892a9ad4e0, thd=0x55892a79ae68, lock_type=1) at ../sql/handler.cc:6770
#2  0x00005589274cf253 in ha_partition::external_lock (this=0x55892a9ac490, thd=0x55892a79ae68, lock_type=1) at ../sql/ha_partition.cc:4072
#3  0x00005589270e0d0a in handler::ha_external_lock (this=0x55892a9ac490, thd=0x55892a79ae68, lock_type=1) at ../sql/handler.cc:6770
#4  0x0000558927285fdb in lock_external (thd=0x55892a79ae68, tables=0x55892a7ae698, count=1) at ../sql/lock.cc:393
#5  0x0000558927285aee in mysql_lock_tables (thd=0x55892a79ae68, sql_lock=0x55892a7ae678, flags=0) at ../sql/lock.cc:338
#6  0x0000558927284b1d in mysql_lock_tables (thd=0x55892a79ae68, tables=0x55892a7ae670, count=1, flags=0) at ../sql/lock.cc:301
#7  0x0000558926be957c in lock_tables (thd=0x55892a79ae68, tables=0x55892a7ad078, count=1, flags=0) at ../sql/sql_base.cc:5538
#8  0x0000558926beacb4 in open_and_lock_tables (thd=0x55892a79ae68, options=..., tables=0x55892a7ad078, derived=true, flags=0, prelocking_strategy=0x7f00cc059ae0) at ../sql/sql_base.cc:5250
#9  0x0000558926b8cc70 in open_and_lock_tables (thd=0x55892a79ae68, tables=0x55892a7ad078, derived=true, flags=0) at ../sql/sql_base.h:509
#10 0x0000558926c541b8 in mysql_insert (thd=0x55892a79ae68, table_list=0x55892a7ad078, fields=..., values_list=..., update_fields=..., update_values=..., duplic=DUP_ERROR, ignore=false, result=0x0) at ../sql/sql_insert.cc:756
#11 0x0000558926cc0179 in mysql_execute_command (thd=0x55892a79ae68) at ../sql/sql_parse.cc:4556
#12 0x0000558926cb3821 in mysql_parse (thd=0x55892a79ae68, rawbuf=0x55892a7acfa0 "INSERT INTO t VALUES (0)", length=24, parser_state=0x7f00cc05c2d8) at ../sql/sql_parse.cc:8016
#13 0x0000558926cb00b2 in dispatch_command (command=COM_QUERY, thd=0x55892a79ae68, packet=0x55892a7a3ad9 "INSERT INTO t VALUES (0)", packet_length=24, blocking=true) at ../sql/sql_parse.cc:1897
#14 0x0000558926cb4ad5 in do_command (thd=0x55892a79ae68, blocking=true) at ../sql/sql_parse.cc:1406
#15 0x0000558926ebcf24 in do_handle_one_connection (connect=0x55892a75b5f8, put_in_cache=true) at ../sql/sql_connect.cc:1410
#16 0x0000558926ebcc5a in handle_one_connection (arg=0x55892a749998) at ../sql/sql_connect.cc:1312
#17 0x00005589274f0349 in pfs_spawn_thread (arg=0x55892a6a3f98) at ../storage/perfschema/pfs.cc:2201
#18 0x00007f00d479a299 in start_thread () from /usr/lib/libpthread.so.0
#19 0x00007f00d44c3053 in clone () from /usr/lib/libc.so.6
(gdb) p trx->bulk_insert
$4 = false
(gdb) c
Continuing.
 
Thread 2 hit Breakpoint 3, ha_innobase::external_lock (this=0x55892a9acd00, thd=0x55892a79ae68, lock_type=2) at ../storage/innobase/handler/ha_innodb.cc:15483
15483		switch (sql_command) {
(gdb) bt
#0  ha_innobase::external_lock (this=0x55892a9acd00, thd=0x55892a79ae68, lock_type=2) at ../storage/innobase/handler/ha_innodb.cc:15483
#1  0x00005589270e0d72 in handler::ha_external_lock (this=0x55892a9acd00, thd=0x55892a79ae68, lock_type=2) at ../sql/handler.cc:6770
#2  0x00005589274cf253 in ha_partition::external_lock (this=0x55892a9ac490, thd=0x55892a79ae68, lock_type=2) at ../sql/ha_partition.cc:4072
#3  0x00005589270e0d0a in handler::ha_external_lock (this=0x55892a9ac490, thd=0x55892a79ae68, lock_type=2) at ../sql/handler.cc:6770
#4  0x0000558926dfc712 in handler::ha_external_unlock (this=0x55892a9ac490, thd=0x55892a79ae68) at ../sql/handler.h:3532
#5  0x00005589272861a1 in unlock_external (thd=0x55892a79ae68, table=0x55892a7ae698, count=1) at ../sql/lock.cc:727
#6  0x0000558927286346 in mysql_unlock_tables (thd=0x55892a79ae68, sql_lock=0x55892a7ae678, free_lock=false) at ../sql/lock.cc:432
#7  0x00005589272865ee in mysql_unlock_tables (thd=0x55892a79ae68, sql_lock=0x55892a7ae678) at ../sql/lock.cc:415
#8  0x0000558926bdf28f in close_thread_tables (thd=0x55892a79ae68) at ../sql/sql_base.cc:913
#9  0x0000558926cc7fee in mysql_execute_command (thd=0x55892a79ae68) at ../sql/sql_parse.cc:6049
#10 0x0000558926cb3821 in mysql_parse (thd=0x55892a79ae68, rawbuf=0x55892a7acfa0 "INSERT INTO t VALUES (0)", length=24, parser_state=0x7f00cc05c2d8) at ../sql/sql_parse.cc:8016
#11 0x0000558926cb00b2 in dispatch_command (command=COM_QUERY, thd=0x55892a79ae68, packet=0x55892a7a3ad9 "INSERT INTO t VALUES (0)", packet_length=24, blocking=true) at ../sql/sql_parse.cc:1897
#12 0x0000558926cb4ad5 in do_command (thd=0x55892a79ae68, blocking=true) at ../sql/sql_parse.cc:1406
#13 0x0000558926ebcf24 in do_handle_one_connection (connect=0x55892a75b5f8, put_in_cache=true) at ../sql/sql_connect.cc:1410
#14 0x0000558926ebcc5a in handle_one_connection (arg=0x55892a749998) at ../sql/sql_connect.cc:1312
#15 0x00005589274f0349 in pfs_spawn_thread (arg=0x55892a6a3f98) at ../storage/perfschema/pfs.cc:2201
#16 0x00007f00d479a299 in start_thread () from /usr/lib/libpthread.so.0
#17 0x00007f00d44c3053 in clone () from /usr/lib/libc.so.6
(gdb) p trx->bulk_insert
$5 = false
(gdb) c
Continuing.
 
Thread 2 hit Breakpoint 3, ha_innobase::external_lock (this=0x55892a9ad4e0, thd=0x55892a79ae68, lock_type=2) at ../storage/innobase/handler/ha_innodb.cc:15483
15483		switch (sql_command) {
(gdb) bt
#0  ha_innobase::external_lock (this=0x55892a9ad4e0, thd=0x55892a79ae68, lock_type=2) at ../storage/innobase/handler/ha_innodb.cc:15483
#1  0x00005589270e0d72 in handler::ha_external_lock (this=0x55892a9ad4e0, thd=0x55892a79ae68, lock_type=2) at ../sql/handler.cc:6770
#2  0x00005589274cf253 in ha_partition::external_lock (this=0x55892a9ac490, thd=0x55892a79ae68, lock_type=2) at ../sql/ha_partition.cc:4072
#3  0x00005589270e0d0a in handler::ha_external_lock (this=0x55892a9ac490, thd=0x55892a79ae68, lock_type=2) at ../sql/handler.cc:6770
#4  0x0000558926dfc712 in handler::ha_external_unlock (this=0x55892a9ac490, thd=0x55892a79ae68) at ../sql/handler.h:3532
#5  0x00005589272861a1 in unlock_external (thd=0x55892a79ae68, table=0x55892a7ae698, count=1) at ../sql/lock.cc:727
#6  0x0000558927286346 in mysql_unlock_tables (thd=0x55892a79ae68, sql_lock=0x55892a7ae678, free_lock=false) at ../sql/lock.cc:432
#7  0x00005589272865ee in mysql_unlock_tables (thd=0x55892a79ae68, sql_lock=0x55892a7ae678) at ../sql/lock.cc:415
#8  0x0000558926bdf28f in close_thread_tables (thd=0x55892a79ae68) at ../sql/sql_base.cc:913
#9  0x0000558926cc7fee in mysql_execute_command (thd=0x55892a79ae68) at ../sql/sql_parse.cc:6049
#10 0x0000558926cb3821 in mysql_parse (thd=0x55892a79ae68, rawbuf=0x55892a7acfa0 "INSERT INTO t VALUES (0)", length=24, parser_state=0x7f00cc05c2d8) at ../sql/sql_parse.cc:8016
#11 0x0000558926cb00b2 in dispatch_command (command=COM_QUERY, thd=0x55892a79ae68, packet=0x55892a7a3ad9 "INSERT INTO t VALUES (0)", packet_length=24, blocking=true) at ../sql/sql_parse.cc:1897
#12 0x0000558926cb4ad5 in do_command (thd=0x55892a79ae68, blocking=true) at ../sql/sql_parse.cc:1406
#13 0x0000558926ebcf24 in do_handle_one_connection (connect=0x55892a75b5f8, put_in_cache=true) at ../sql/sql_connect.cc:1410
#14 0x0000558926ebcc5a in handle_one_connection (arg=0x55892a749998) at ../sql/sql_connect.cc:1312
#15 0x00005589274f0349 in pfs_spawn_thread (arg=0x55892a6a3f98) at ../storage/perfschema/pfs.cc:2201
#16 0x00007f00d479a299 in start_thread () from /usr/lib/libpthread.so.0
#17 0x00007f00d44c3053 in clone () from /usr/lib/libc.so.6
(gdb) p trx->bulk_insert
$6 = false
(gdb) c
Continuing.
 
Thread 2 hit Breakpoint 2, mysql_insert (thd=0x55892a79ae68, table_list=0x55892a7ad088, fields=..., values_list=..., update_fields=..., update_values=..., duplic=DUP_ERROR, ignore=false, result=0x0) at ../sql/sql_insert.cc:711
711	  Name_resolution_context_state ctx_state;
(gdb) p thd->query()
$7 = 0x55892a7acfa0 "INSERT INTO t VALUES (1),(0),(1)"
(gdb) c
Continuing.
 
Thread 2 hit Breakpoint 3, ha_innobase::external_lock (this=0x55892a9acd00, thd=0x55892a79ae68, lock_type=1) at ../storage/innobase/handler/ha_innodb.cc:15483
15483		switch (sql_command) {
(gdb) p trx->bulk_insert
$8 = false
(gdb) bt
#0  ha_innobase::external_lock (this=0x55892a9acd00, thd=0x55892a79ae68, lock_type=1) at ../storage/innobase/handler/ha_innodb.cc:15483
#1  0x00005589270e0d72 in handler::ha_external_lock (this=0x55892a9acd00, thd=0x55892a79ae68, lock_type=1) at ../sql/handler.cc:6770
#2  0x00005589274cf253 in ha_partition::external_lock (this=0x55892a9ac490, thd=0x55892a79ae68, lock_type=1) at ../sql/ha_partition.cc:4072
#3  0x00005589270e0d0a in handler::ha_external_lock (this=0x55892a9ac490, thd=0x55892a79ae68, lock_type=1) at ../sql/handler.cc:6770
#4  0x0000558927285fdb in lock_external (thd=0x55892a79ae68, tables=0x55892a7ae818, count=1) at ../sql/lock.cc:393
#5  0x0000558927285aee in mysql_lock_tables (thd=0x55892a79ae68, sql_lock=0x55892a7ae7f8, flags=0) at ../sql/lock.cc:338
#6  0x0000558927284b1d in mysql_lock_tables (thd=0x55892a79ae68, tables=0x55892a7ae7f0, count=1, flags=0) at ../sql/lock.cc:301
#7  0x0000558926be957c in lock_tables (thd=0x55892a79ae68, tables=0x55892a7ad088, count=1, flags=0) at ../sql/sql_base.cc:5538
#8  0x0000558926beacb4 in open_and_lock_tables (thd=0x55892a79ae68, options=..., tables=0x55892a7ad088, derived=true, flags=0, prelocking_strategy=0x7f00cc059ae0) at ../sql/sql_base.cc:5250
#9  0x0000558926b8cc70 in open_and_lock_tables (thd=0x55892a79ae68, tables=0x55892a7ad088, derived=true, flags=0) at ../sql/sql_base.h:509
#10 0x0000558926c541b8 in mysql_insert (thd=0x55892a79ae68, table_list=0x55892a7ad088, fields=..., values_list=..., update_fields=..., update_values=..., duplic=DUP_ERROR, ignore=false, result=0x0) at ../sql/sql_insert.cc:756
#11 0x0000558926cc0179 in mysql_execute_command (thd=0x55892a79ae68) at ../sql/sql_parse.cc:4556
#12 0x0000558926cb3821 in mysql_parse (thd=0x55892a79ae68, rawbuf=0x55892a7acfa0 "INSERT INTO t VALUES (1),(0),(1)", length=32, parser_state=0x7f00cc05c2d8) at ../sql/sql_parse.cc:8016
#13 0x0000558926cb00b2 in dispatch_command (command=COM_QUERY, thd=0x55892a79ae68, packet=0x55892a7a3ad9 "INSERT INTO t VALUES (1),(0),(1)", packet_length=32, blocking=true) at ../sql/sql_parse.cc:1897
#14 0x0000558926cb4ad5 in do_command (thd=0x55892a79ae68, blocking=true) at ../sql/sql_parse.cc:1406
#15 0x0000558926ebcf24 in do_handle_one_connection (connect=0x55892a75b5f8, put_in_cache=true) at ../sql/sql_connect.cc:1410
#16 0x0000558926ebcc5a in handle_one_connection (arg=0x55892a749998) at ../sql/sql_connect.cc:1312
#17 0x00005589274f0349 in pfs_spawn_thread (arg=0x55892a6a3f98) at ../storage/perfschema/pfs.cc:2201
#18 0x00007f00d479a299 in start_thread () from /usr/lib/libpthread.so.0
#19 0x00007f00d44c3053 in clone () from /usr/lib/libc.so.6
(gdb) c
Continuing.
 
Thread 2 hit Breakpoint 3, ha_innobase::external_lock (this=0x55892a9ad4e0, thd=0x55892a79ae68, lock_type=1) at ../storage/innobase/handler/ha_innodb.cc:15483
15483		switch (sql_command) {
(gdb) bt
#0  ha_innobase::external_lock (this=0x55892a9ad4e0, thd=0x55892a79ae68, lock_type=1) at ../storage/innobase/handler/ha_innodb.cc:15483
#1  0x00005589270e0d72 in handler::ha_external_lock (this=0x55892a9ad4e0, thd=0x55892a79ae68, lock_type=1) at ../sql/handler.cc:6770
#2  0x00005589274cf253 in ha_partition::external_lock (this=0x55892a9ac490, thd=0x55892a79ae68, lock_type=1) at ../sql/ha_partition.cc:4072
#3  0x00005589270e0d0a in handler::ha_external_lock (this=0x55892a9ac490, thd=0x55892a79ae68, lock_type=1) at ../sql/handler.cc:6770
#4  0x0000558927285fdb in lock_external (thd=0x55892a79ae68, tables=0x55892a7ae818, count=1) at ../sql/lock.cc:393
#5  0x0000558927285aee in mysql_lock_tables (thd=0x55892a79ae68, sql_lock=0x55892a7ae7f8, flags=0) at ../sql/lock.cc:338
#6  0x0000558927284b1d in mysql_lock_tables (thd=0x55892a79ae68, tables=0x55892a7ae7f0, count=1, flags=0) at ../sql/lock.cc:301
#7  0x0000558926be957c in lock_tables (thd=0x55892a79ae68, tables=0x55892a7ad088, count=1, flags=0) at ../sql/sql_base.cc:5538
#8  0x0000558926beacb4 in open_and_lock_tables (thd=0x55892a79ae68, options=..., tables=0x55892a7ad088, derived=true, flags=0, prelocking_strategy=0x7f00cc059ae0) at ../sql/sql_base.cc:5250
#9  0x0000558926b8cc70 in open_and_lock_tables (thd=0x55892a79ae68, tables=0x55892a7ad088, derived=true, flags=0) at ../sql/sql_base.h:509
#10 0x0000558926c541b8 in mysql_insert (thd=0x55892a79ae68, table_list=0x55892a7ad088, fields=..., values_list=..., update_fields=..., update_values=..., duplic=DUP_ERROR, ignore=false, result=0x0) at ../sql/sql_insert.cc:756
#11 0x0000558926cc0179 in mysql_execute_command (thd=0x55892a79ae68) at ../sql/sql_parse.cc:4556
#12 0x0000558926cb3821 in mysql_parse (thd=0x55892a79ae68, rawbuf=0x55892a7acfa0 "INSERT INTO t VALUES (1),(0),(1)", length=32, parser_state=0x7f00cc05c2d8) at ../sql/sql_parse.cc:8016
#13 0x0000558926cb00b2 in dispatch_command (command=COM_QUERY, thd=0x55892a79ae68, packet=0x55892a7a3ad9 "INSERT INTO t VALUES (1),(0),(1)", packet_length=32, blocking=true) at ../sql/sql_parse.cc:1897
#14 0x0000558926cb4ad5 in do_command (thd=0x55892a79ae68, blocking=true) at ../sql/sql_parse.cc:1406
#15 0x0000558926ebcf24 in do_handle_one_connection (connect=0x55892a75b5f8, put_in_cache=true) at ../sql/sql_connect.cc:1410
#16 0x0000558926ebcc5a in handle_one_connection (arg=0x55892a749998) at ../sql/sql_connect.cc:1312
#17 0x00005589274f0349 in pfs_spawn_thread (arg=0x55892a6a3f98) at ../storage/perfschema/pfs.cc:2201
#18 0x00007f00d479a299 in start_thread () from /usr/lib/libpthread.so.0
#19 0x00007f00d44c3053 in clone () from /usr/lib/libc.so.6
(gdb) p trx->bulk_insert
$9 = false
(gdb) c
Continuing.
 
Thread 2 received signal SIGABRT, Aborted.
0x00007f00d4400ef5 in raise () from /usr/lib/libc.so.6

Comment by Marko Mäkelä [ 2021-06-28 ]

It seems that the code removal that I suggested earlier could do the trick. All mtr tests passed.

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