[MDEV-31565] Assertion fails in ha_maria::close upon DML on partitioned Aria table via stored function Created: 2023-06-27  Updated: 2023-11-28

Status: Open
Project: MariaDB Server
Component/s: Partitioning, Storage Engine - Aria
Affects Version/s: 10.4, 10.5, 10.6, 10.9, 10.10, 10.11, 11.0, 11.1
Fix Version/s: 10.4, 10.5, 10.6, 10.11, 11.0, 11.1

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


 Description   

--source include/have_partition.inc
 
CREATE TABLE t (a int, b int, c int, key (a), key (b))
ENGINE=Aria
PARTITION BY range (c) (
  partition p0 values less than (10),
  partition pm values less than maxvalue
);
INSERT INTO t VALUES (1,2,0),(2,2,0),(3,0,0);
 
--delimiter $
CREATE FUNCTION f() RETURNS INT NOT DETERMINISTIC
BEGIN
  DELETE FROM t PARTITION (p0) WHERE t.b = 7 OR t.a = 0;
  RETURN 0;
END $
--delimiter ;
SELECT f();
 
# Cleanup
DROP FUNCTION f;
DROP TABLE t;

10.4 f5dceafd

mysqld: /data/src/10.4/storage/maria/ha_maria.cc:1239: virtual int ha_maria::close(): Assertion `file->trn == 0 || file->trn == &dummy_transaction_object' failed.
230628  1:21:46 [ERROR] mysqld got signal 6 ;
 
#9  0x00007fe8a1a53df2 in __GI___assert_fail (assertion=0x562b9058aba0 "file->trn == 0 || file->trn == &dummy_transaction_object", file=0x562b9058a140 "/data/src/10.4/storage/maria/ha_maria.cc", line=1239, function=0x562b9058ac00 "virtual int ha_maria::close()") at ./assert/assert.c:101
#10 0x0000562b8edc2fce in ha_maria::close (this=0x621000096890) at /data/src/10.4/storage/maria/ha_maria.cc:1239
#11 0x0000562b8e82af9c in handler::ha_close (this=0x621000096890) at /data/src/10.4/sql/handler.cc:2874
#12 0x0000562b8f00bc14 in ha_partition::close (this=0x621000094f90) at /data/src/10.4/sql/ha_partition.cc:3937
#13 0x0000562b8e82af9c in handler::ha_close (this=0x621000094f90) at /data/src/10.4/sql/handler.cc:2874
#14 0x0000562b8ebcdf61 in QUICK_RANGE_SELECT::~QUICK_RANGE_SELECT (this=0x613000050d80, __in_chrg=<optimized out>) at /data/src/10.4/sql/opt_range.cc:1350
#15 0x0000562b8ebce13e in QUICK_RANGE_SELECT::~QUICK_RANGE_SELECT (this=0x613000050d80, __in_chrg=<optimized out>) at /data/src/10.4/sql/opt_range.cc:1359
#16 0x0000562b8ec3f4cd in List<QUICK_SELECT_I>::delete_elements (this=0x61100002d1c0) at /data/src/10.4/sql/sql_list.h:525
#17 0x0000562b8ebd2c48 in QUICK_ROR_UNION_SELECT::~QUICK_ROR_UNION_SELECT (this=0x61100002d180, __in_chrg=<optimized out>) at /data/src/10.4/sql/opt_range.cc:1853
#18 0x0000562b8ebd2e14 in QUICK_ROR_UNION_SELECT::~QUICK_ROR_UNION_SELECT (this=0x61100002d180, __in_chrg=<optimized out>) at /data/src/10.4/sql/opt_range.cc:1858
#19 0x0000562b8ebcccc3 in SQL_SELECT::cleanup (this=0x625000110b60) at /data/src/10.4/sql/opt_range.cc:1233
#20 0x0000562b8ebcce20 in SQL_SELECT::~SQL_SELECT (this=0x625000110b60, __in_chrg=<optimized out>) at /data/src/10.4/sql/opt_range.cc:1247
#21 0x0000562b8ec9d312 in mysql_delete (thd=0x62b00005b208, table_list=0x6250001029c0, conds=0x62500010ae08, order_list=0x625000104cc8, limit=18446744073709551615, options=0, result=0x0) at /data/src/10.4/sql/sql_delete.cc:908
#22 0x0000562b8e0803da in mysql_execute_command (thd=0x62b00005b208) at /data/src/10.4/sql/sql_parse.cc:4815
#23 0x0000562b8de3b5bc in sp_instr_stmt::exec_core (this=0x625000103828, thd=0x62b00005b208, nextp=0x7fe899cf5e90) at /data/src/10.4/sql/sp_head.cc:3694
#24 0x0000562b8de39cdd in sp_lex_keeper::reset_lex_and_exec_core (this=0x625000103870, thd=0x62b00005b208, nextp=0x7fe899cf5e90, open_tables=false, instr=0x625000103828) at /data/src/10.4/sql/sp_head.cc:3424
#25 0x0000562b8de3ad53 in sp_instr_stmt::execute (this=0x625000103828, thd=0x62b00005b208, nextp=0x7fe899cf5e90) at /data/src/10.4/sql/sp_head.cc:3600
#26 0x0000562b8de2c379 in sp_head::execute (this=0x625000101928, thd=0x62b00005b208, merge_da_on_success=true) at /data/src/10.4/sql/sp_head.cc:1365
#27 0x0000562b8de3057a in sp_head::execute_function (this=0x625000101928, thd=0x62b00005b208, argp=0x0, argcount=0, return_value_fld=0x62b000065aa8, func_ctx=0x62b000062ac0, call_arena=0x62b000063ea8) at /data/src/10.4/sql/sp_head.cc:2088
#28 0x0000562b8e879bbd in Item_sp::execute_impl (this=0x62b000062a60, thd=0x62b00005b208, args=0x0, arg_count=0) at /data/src/10.4/sql/item.cc:2846
#29 0x0000562b8e879157 in Item_sp::execute (this=0x62b000062a60, thd=0x62b00005b208, null_value=0x62b000062a16, args=0x0, arg_count=0) at /data/src/10.4/sql/item.cc:2761
#30 0x0000562b8e9ad5db in Item_func_sp::execute (this=0x62b0000629a0) at /data/src/10.4/sql/item_func.cc:6510
#31 0x0000562b8e9bd33a in Item_func_sp::val_int (this=0x62b0000629a0) at /data/src/10.4/sql/item_func.h:3292
#32 0x0000562b8e5ed7d2 in Type_handler::Item_send_long (this=0x562b91233000 <type_handler_long>, item=0x62b0000629a0, protocol=0x62b00005b808, buf=0x7fe899cf6d70) at /data/src/10.4/sql/sql_type.cc:7106
#33 0x0000562b8e606d02 in Type_handler_long::Item_send (this=0x562b91233000 <type_handler_long>, item=0x62b0000629a0, protocol=0x62b00005b808, buf=0x7fe899cf6d70) at /data/src/10.4/sql/sql_type.h:5191
#34 0x0000562b8ddc484c in Item::send (this=0x62b0000629a0, protocol=0x62b00005b808, buffer=0x7fe899cf6d70) at /data/src/10.4/sql/item.h:1044
#35 0x0000562b8ddb68e9 in Protocol::send_result_set_row (this=0x62b00005b808, row_items=0x62b000062410) at /data/src/10.4/sql/protocol.cc:1038
#36 0x0000562b8df613bb in select_send::send_data (this=0x62b000065308, items=...) at /data/src/10.4/sql/sql_class.cc:3139
#37 0x0000562b8e149bf0 in JOIN::exec_inner (this=0x62b000065338) at /data/src/10.4/sql/sql_select.cc:4473
#38 0x0000562b8e1487c4 in JOIN::exec (this=0x62b000065338) at /data/src/10.4/sql/sql_select.cc:4387
#39 0x0000562b8e14c856 in mysql_select (thd=0x62b00005b208, tables=0x0, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147748608, result=0x62b000065308, unit=0x62b00005f140, select_lex=0x62b0000622b0) at /data/src/10.4/sql/sql_select.cc:4826
#40 0x0000562b8e11d461 in handle_select (thd=0x62b00005b208, lex=0x62b00005f080, result=0x62b000065308, setup_tables_done_option=0) at /data/src/10.4/sql/sql_select.cc:442
#41 0x0000562b8e08d28b in execute_sqlcom_select (thd=0x62b00005b208, all_tables=0x0) at /data/src/10.4/sql/sql_parse.cc:6473
#42 0x0000562b8e07a7a0 in mysql_execute_command (thd=0x62b00005b208) at /data/src/10.4/sql/sql_parse.cc:3976
#43 0x0000562b8e096463 in mysql_parse (thd=0x62b00005b208, rawbuf=0x62b000062228 "SELECT f()", length=10, parser_state=0x7fe899cf9860, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:8008
#44 0x0000562b8e06c7a6 in dispatch_command (command=COM_QUERY, thd=0x62b00005b208, packet=0x629000230209 "", packet_length=10, is_com_multi=false, is_next_command=false) at /data/src/10.4/sql/sql_parse.cc:1857
#45 0x0000562b8e069315 in do_command (thd=0x62b00005b208) at /data/src/10.4/sql/sql_parse.cc:1378
#46 0x0000562b8e4680ba in do_handle_one_connection (connect=0x6080000009a8) at /data/src/10.4/sql/sql_connect.cc:1420
#47 0x0000562b8e4679d1 in handle_one_connection (arg=0x6080000009a8) at /data/src/10.4/sql/sql_connect.cc:1324
#48 0x0000562b8f0d4aee in pfs_spawn_thread (arg=0x615000003508) at /data/src/10.4/storage/perfschema/pfs.cc:1869
#49 0x00007fe8a1aa7fd4 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#50 0x00007fe8a1b285bc in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

Reproducible on all existing versions, also on earlier minor releases.
No obvious immediate problem on a non-debug build.
No obvious problems with InnoDB or MyISAM.


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