[MDEV-26175] Assertion `! thd->in_sub_stmt' failed in bool trans_rollback_stmt(THD*) Created: 2021-07-19  Updated: 2023-04-12  Resolved: 2023-04-12

Status: Closed
Project: MariaDB Server
Component/s: Galera
Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6
Fix Version/s: 11.1.1, 10.11.3, 10.4.29, 10.5.20, 10.6.13, 10.8.8, 10.9.6, 10.10.4

Type: Bug Priority: Major
Reporter: Ramesh Sivaraman Assignee: Julius Goryavsky
Resolution: Fixed Votes: 0
Labels: None


 Description   

SET sql_mode="no_zero_date";
SET GLOBAL wsrep_max_ws_rows=1;
CREATE TABLE t2 (a INT);
CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
CREATE TRIGGER tgr BEFORE INSERT ON t1 FOR EACH ROW INSERT INTO t2 VALUES (0);
CREATE TABLE ti (id BIGINT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO ti VALUES (1);
INSERT INTO t1 VALUES (0),(1);

Leads to:

10.6.4 a8410693dccf206ca58089c72449cc78d03dd612 (Debug)

mysqld: /test/10.6_dbg/sql/transaction.cc:529: bool trans_rollback_stmt(THD*): Assertion `! thd->in_sub_stmt' failed.

10.6.4 a8410693dccf206ca58089c72449cc78d03dd612 (Debug)

Core was generated by `/test/GAL_MD120721-mariadb-10.6.4-linux-x86_64-dbg/bin/mysqld --defaults-file=/'.
Program terminated with signal SIGABRT, Aborted.
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6)
    at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
[Current thread is 1 (Thread 0x1470bc5dc700 (LWP 3345316))]
(gdb) bt
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
#1  0x00005619514e6c97 in my_write_core (sig=sig@entry=6) at /test/10.6_dbg/mysys/stacktrace.c:424
#2  0x0000561950c9a616 in handle_fatal_signal (sig=6) at /test/10.6_dbg/sql/signal_handler.cc:344
#3  <signal handler called>
#4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#5  0x00001470cd7cd859 in __GI_abort () at abort.c:79
#6  0x00001470cd7cd729 in __assert_fail_base (fmt=0x1470cd963588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x56195166bfc6 "! thd->in_sub_stmt", file=0x561951698578 "/test/10.6_dbg/sql/transaction.cc", line=529, function=<optimized out>) at assert.c:92
#7  0x00001470cd7def36 in __GI___assert_fail (assertion=assertion@entry=0x56195166bfc6 "! thd->in_sub_stmt", file=file@entry=0x561951698578 "/test/10.6_dbg/sql/transaction.cc", line=line@entry=529, function=function@entry=0x561951698a98 "bool trans_rollback_stmt(THD*)") at assert.c:101
#8  0x0000561950b2fcf2 in trans_rollback_stmt (thd=thd@entry=0x147054000db8) at /test/10.6_dbg/sql/transaction.cc:529
#9  0x0000561950c9dcae in wsrep_after_row (thd=0x147054000db8) at /test/10.6_dbg/sql/handler.cc:7112
#10 0x0000561950caf0e9 in handler::ha_write_row (this=0x1470540bf7b0, buf=0x1470540bf348 <incomplete sequence \375>) at /test/10.6_dbg/sql/handler.cc:7510
#11 0x0000561950964ac8 in write_record (thd=thd@entry=0x147054000db8, table=table@entry=0x1470540beeb8, info=info@entry=0x1470bc5d97a0, sink=sink@entry=0x0) at /test/10.6_dbg/sql/sql_insert.cc:2113
#12 0x00005619509706ad in mysql_insert (thd=thd@entry=0x147054000db8, table_list=0x1470540b4a50, fields=@0x1470540b6d90: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x561951fbe980 <end_of_list>, last = 0x1470540b6d90, elements = 0}, <No data fields>}, values_list=@0x1470540b6dd8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x1470540b5650, last = 0x1470540b5650, elements = 1}, <No data fields>}, update_fields=@0x1470540b6dc0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x561951fbe980 <end_of_list>, last = 0x1470540b6dc0, elements = 0}, <No data fields>}, update_values=@0x1470540b6da8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x561951fbe980 <end_of_list>, last = 0x1470540b6da8, elements = 0}, <No data fields>}, duplic=DUP_ERROR, ignore=false, result=0x0) at /test/10.6_dbg/sql/sql_insert.cc:1104
#13 0x00005619509b69b2 in mysql_execute_command (thd=0x147054000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.6_dbg/sql/sql_parse.cc:4566
#14 0x00005619508d2908 in sp_instr_stmt::exec_core (this=0x1470540b56c8, thd=<optimized out>, nextp=0x1470bc5da34c) at /test/10.6_dbg/sql/sp_head.cc:3772
#15 0x00005619508e0c6f in sp_lex_keeper::reset_lex_and_exec_core (this=this@entry=0x1470540b5710, thd=thd@entry=0x147054000db8, nextp=nextp@entry=0x1470bc5da34c, open_tables=open_tables@entry=false, instr=instr@entry=0x1470540b56c8) at /test/10.6_dbg/sql/sp_head.cc:3499
#16 0x00005619508e17e2 in sp_instr_stmt::execute (this=0x1470540b56c8, thd=0x147054000db8, nextp=0x1470bc5da34c) at /test/10.6_dbg/sql/sp_head.cc:3678
#17 0x00005619508d93e0 in sp_head::execute (this=this@entry=0x1470540b3b30, thd=thd@entry=0x147054000db8, merge_da_on_success=merge_da_on_success@entry=false) at /test/10.6_dbg/sql/sp_head.cc:1437
#18 0x00005619508da7be in sp_head::execute_trigger (this=0x1470540b3b30, thd=thd@entry=0x147054000db8, db_name=0x1470540adb10, table_name=<optimized out>, grant_info=grant_info@entry=0x1470540b3810) at /test/10.6_dbg/sql/sp_head.cc:1918
#19 0x0000561950a9a760 in Table_triggers_list::process_triggers (this=this@entry=0x1470540b3250, thd=thd@entry=0x147054000db8, event=event@entry=TRG_EVENT_INSERT, time_type=time_type@entry=TRG_ACTION_BEFORE, old_row_is_record1=old_row_is_record1@entry=true) at /test/10.6_dbg/sql/sql_trigger.cc:2453
#20 0x000056195092acc1 in fill_record_n_invoke_before_triggers (thd=thd@entry=0x147054000db8, table=table@entry=0x1470540b0038, ptr=0x1470540b3888, values=@0x147054014ca8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x147054014d40, last = 0x147054014d40, elements = 1}, <No data fields>}, ignore_errors=ignore_errors@entry=false, event=event@entry=TRG_EVENT_INSERT) at /test/10.6_dbg/sql/sql_base.cc:8892
#21 0x000056195096fb05 in mysql_insert (thd=thd@entry=0x147054000db8, table_list=0x147054014090, fields=@0x147054005fd8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x561951fbe980 <end_of_list>, last = 0x147054005fd8, elements = 0}, <No data fields>}, values_list=@0x147054006020: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x147054014c98, last = 0x147054014d50, elements = 2}, <No data fields>}, update_fields=@0x147054006008: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x561951fbe980 <end_of_list>, last = 0x147054006008, elements = 0}, <No data fields>}, update_values=@0x147054005ff0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x561951fbe980 <end_of_list>, last = 0x147054005ff0, elements = 0}, <No data fields>}, duplic=DUP_ERROR, ignore=false, result=0x0) at /test/10.6_dbg/sql/sql_insert.cc:1047
#22 0x00005619509b69b2 in mysql_execute_command (thd=thd@entry=0x147054000db8, is_called_from_prepared_stmt=is_called_from_prepared_stmt@entry=false) at /test/10.6_dbg/sql/sql_parse.cc:4566
#23 0x00005619509a1591 in mysql_parse (thd=thd@entry=0x147054000db8, rawbuf=rawbuf@entry=0x147054013fb0 "INSERT INTO t1 VALUES (0),(1)", length=length@entry=29, parser_state=parser_state@entry=0x1470bc5db400) at /test/10.6_dbg/sql/sql_parse.cc:8026
#24 0x00005619509a0f25 in wsrep_mysql_parse (thd=thd@entry=0x147054000db8, rawbuf=0x147054013fb0 "INSERT INTO t1 VALUES (0),(1)", length=29, parser_state=parser_state@entry=0x1470bc5db400) at /test/10.6_dbg/sql/sql_parse.cc:7840
#25 0x00005619509b01dd in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x147054000db8, packet=packet@entry=0x14705400b769 "INSERT INTO t1 VALUES (0),(1)", packet_length=packet_length@entry=29, blocking=blocking@entry=true) at /test/10.6_dbg/sql/sql_class.h:1340
#26 0x00005619509b35e7 in do_command (thd=0x147054000db8, blocking=blocking@entry=true) at /test/10.6_dbg/sql/sql_parse.cc:1404
#27 0x0000561950b1914f in do_handle_one_connection (connect=<optimized out>, connect@entry=0x56195473beb8, put_in_cache=put_in_cache@entry=true) at /test/10.6_dbg/sql/sql_connect.cc:1410
#28 0x0000561950b19757 in handle_one_connection (arg=arg@entry=0x56195473beb8) at /test/10.6_dbg/sql/sql_connect.cc:1312
#29 0x0000561950fcb1e5 in pfs_spawn_thread (arg=0x5619547b3948) at /test/10.6_dbg/storage/perfschema/pfs.cc:2201
#30 0x00001470cdcdb609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#31 0x00001470cd8ca293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

10.3.30 1447b39475d2900066e0d058cee9b3fa6aec5016 (Debug)

mysqld: /test/10.3_dbg/sql/transaction.cc:560: bool trans_rollback_stmt(THD*): Assertion `! thd->in_sub_stmt' failed.

10.3.30 1447b39475d2900066e0d058cee9b3fa6aec5016 (Debug)

Core was generated by `/test/GAL_MD120521-mariadb-10.3.30-linux-x86_64-dbg/bin/mysqld --defaults-file='.
Program terminated with signal SIGABRT, Aborted.
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6)
    at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
[Current thread is 1 (Thread 0x14eab0123700 (LWP 3353446))]
(gdb) bt
#0  __pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ../sysdeps/unix/sysv/linux/pthread_kill.c:56
#1  0x0000556e6948583a in my_write_core (sig=sig@entry=6) at /test/10.3_dbg/mysys/stacktrace.c:386
#2  0x0000556e68c381fa in handle_fatal_signal (sig=6) at /test/10.3_dbg/sql/signal_handler.cc:355
#3  <signal handler called>
#4  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#5  0x000014eaf0f69859 in __GI_abort () at abort.c:79
#6  0x000014eaf0f69729 in __assert_fail_base (fmt=0x14eaf10ff588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x556e6952d8f5 "! thd->in_sub_stmt", file=0x556e69557340 "/test/10.3_dbg/sql/transaction.cc", line=560, function=<optimized out>) at assert.c:92
#7  0x000014eaf0f7af36 in __GI___assert_fail (assertion=assertion@entry=0x556e6952d8f5 "! thd->in_sub_stmt", file=file@entry=0x556e69557340 "/test/10.3_dbg/sql/transaction.cc", line=line@entry=560, function=function@entry=0x556e69557640 "bool trans_rollback_stmt(THD*)") at assert.c:101
#8  0x0000556e68af1116 in trans_rollback_stmt (thd=thd@entry=0x14ea70000d90) at /test/10.3_dbg/sql/transaction.cc:560
#9  0x0000556e68c49366 in binlog_log_row (table=0x14ea703306d0, before_record=before_record@entry=0x0, after_record=after_record@entry=0x14ea70331320 <incomplete sequence \375>, log_func=log_func@entry=0x556e68c4d6c3 <Write_rows_log_event::binlog_row_logging_function(THD*, TABLE*, bool, unsigned char const*, unsigned char const*)>) at /test/10.3_dbg/sql/handler.cc:6348
#10 0x0000556e68c49cec in handler::ha_write_row (this=0x14ea70331778, buf=0x14ea70331320 <incomplete sequence \375>) at /test/10.3_dbg/sql/handler.cc:6485
#11 0x0000556e6896d578 in write_record (thd=thd@entry=0x14ea70000d90, table=table@entry=0x14ea703306d0, info=info@entry=0x14eab011e5a0) at /test/10.3_dbg/sql/sql_insert.cc:2039
#12 0x0000556e6897938b in mysql_insert (thd=thd@entry=0x14ea70000d90, table_list=0x14ea703285b8, fields=@0x14ea7032a790: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x556e69d82f40 <end_of_list>, last = 0x14ea7032a790, elements = 0}, <No data fields>}, values_list=@0x14ea7032a7d8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14ea70328cd0, last = 0x14ea70328cd0, elements = 1}, <No data fields>}, update_fields=@0x14ea7032a7c0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x556e69d82f40 <end_of_list>, last = 0x14ea7032a7c0, elements = 0}, <No data fields>}, update_values=@0x14ea7032a7a8: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x556e69d82f40 <end_of_list>, last = 0x14ea7032a7a8, elements = 0}, <No data fields>}, duplic=DUP_ERROR, ignore=false) at /test/10.3_dbg/sql/sql_insert.cc:1072
#13 0x0000556e689aac0d in mysql_execute_command (thd=0x14ea70000d90) at /test/10.3_dbg/sql/sql_parse.cc:4507
#14 0x0000556e688e4613 in sp_instr_stmt::exec_core (this=0x14ea70328ce0, thd=<optimized out>, nextp=0x14eab012031c) at /test/10.3_dbg/sql/sp_head.cc:3702
#15 0x0000556e688f017c in sp_lex_keeper::reset_lex_and_exec_core (this=this@entry=0x14ea70328d28, thd=thd@entry=0x14ea70000d90, nextp=nextp@entry=0x14eab012031c, open_tables=open_tables@entry=false, instr=instr@entry=0x14ea70328ce0) at /test/10.3_dbg/sql/sp_head.cc:3434
#16 0x0000556e688f0cdb in sp_instr_stmt::execute (this=0x14ea70328ce0, thd=0x14ea70000d90, nextp=0x14eab012031c) at /test/10.3_dbg/sql/sp_head.cc:3608
#17 0x0000556e688e915a in sp_head::execute (this=this@entry=0x14ea70327868, thd=thd@entry=0x14ea70000d90, merge_da_on_success=merge_da_on_success@entry=false) at /test/10.3_dbg/sql/sp_head.cc:1377
#18 0x0000556e688ea2ac in sp_head::execute_trigger (this=0x14ea70327868, thd=thd@entry=0x14ea70000d90, db_name=0x14ea70321300, table_name=0x14ea70321310, grant_info=grant_info@entry=0x14ea70327518) at /test/10.3_dbg/sql/sp_head.cc:1873
#19 0x0000556e68a761d2 in Table_triggers_list::process_triggers (this=this@entry=0x14ea70326fa8, thd=thd@entry=0x14ea70000d90, event=event@entry=TRG_EVENT_INSERT, time_type=time_type@entry=TRG_ACTION_BEFORE, old_row_is_record1=old_row_is_record1@entry=true) at /test/10.3_dbg/sql/sql_trigger.cc:2221
#20 0x0000556e68935d7a in fill_record_n_invoke_before_triggers (thd=thd@entry=0x14ea70000d90, table=table@entry=0x14ea70323690, ptr=0x14ea70327590, values=@0x14ea70011d88: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14ea70011e38, last = 0x14ea70011e38, elements = 1}, <No data fields>}, ignore_errors=ignore_errors@entry=false, event=event@entry=TRG_EVENT_INSERT) at /test/10.3_dbg/sql/sql_base.cc:8744
#21 0x0000556e6897873a in mysql_insert (thd=thd@entry=0x14ea70000d90, table_list=0x14ea70011658, fields=@0x14ea70005a20: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x556e69d82f40 <end_of_list>, last = 0x14ea70005a20, elements = 0}, <No data fields>}, values_list=@0x14ea70005a68: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x14ea70011d78, last = 0x14ea70011e48, elements = 2}, <No data fields>}, update_fields=@0x14ea70005a50: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x556e69d82f40 <end_of_list>, last = 0x14ea70005a50, elements = 0}, <No data fields>}, update_values=@0x14ea70005a38: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x556e69d82f40 <end_of_list>, last = 0x14ea70005a38, elements = 0}, <No data fields>}, duplic=DUP_ERROR, ignore=false) at /test/10.3_dbg/sql/sql_insert.cc:1014
#22 0x0000556e689aac0d in mysql_execute_command (thd=thd@entry=0x14ea70000d90) at /test/10.3_dbg/sql/sql_parse.cc:4507
#23 0x0000556e689b1eb5 in mysql_parse (thd=thd@entry=0x14ea70000d90, rawbuf=rawbuf@entry=0x14ea70011578 "INSERT INTO t1 VALUES (0),(1)", length=length@entry=29, parser_state=parser_state@entry=0x14eab0122540, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.3_dbg/sql/sql_parse.cc:7873
#24 0x0000556e689b3574 in wsrep_mysql_parse (thd=thd@entry=0x14ea70000d90, rawbuf=0x14ea70011578 "INSERT INTO t1 VALUES (0),(1)", length=29, parser_state=parser_state@entry=0x14eab0122540, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.3_dbg/sql/sql_parse.cc:7665
#25 0x0000556e689b468f in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x14ea70000d90, packet=packet@entry=0x14ea700198f1 "INSERT INTO t1 VALUES (0),(1)", packet_length=packet_length@entry=29, is_com_multi=is_com_multi@entry=false, is_next_command=is_next_command@entry=false) at /test/10.3_dbg/sql/sql_class.h:1152
#26 0x0000556e689b781a in do_command (thd=0x14ea70000d90) at /test/10.3_dbg/sql/sql_parse.cc:1398
#27 0x0000556e68adfb80 in do_handle_one_connection (connect=connect@entry=0x556e6c132780) at /test/10.3_dbg/sql/sql_connect.cc:1403
#28 0x0000556e68adfdb7 in handle_one_connection (arg=0x556e6c132780) at /test/10.3_dbg/sql/sql_connect.cc:1308
#29 0x000014eaf113f609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#30 0x000014eaf1066293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Bug confirmed present in:
MariaDB: 10.2.39 (dbg), 10.3.30 (dbg), 10.4.20 (dbg), 10.5.11 (dbg), 10.6.4 (dbg)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.2.39 (opt), 10.3.30 (opt), 10.4.20 (opt), 10.5.11 (opt), 10.6.4 (opt)



 Comments   
Comment by Jan Lindström [ 2023-04-06 ]

https://github.com/MariaDB/server/pull/2591

Comment by Julius Goryavsky [ 2023-04-12 ]

Fix merged with head revision (https://github.com/MariaDB/server/commit/f83b7ae13d9619af29d74a27dd253b67aa0ee4fb)

Comment by Julius Goryavsky [ 2023-04-12 ]

Fix merged with head revision

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