[MDEV-31244] Assertion "not SELECT" in vers_set_hist_part() Created: 2023-05-11  Updated: 2023-07-27  Resolved: 2023-07-27

Status: Closed
Project: MariaDB Server
Component/s: Partitioning, Stored routines, Versioned Tables
Affects Version/s: 10.9, 10.10, 10.11, 11.0
Fix Version/s: 10.9.8, 10.10.6, 10.11.5, 11.0.3, 11.1.2, 11.2.1

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Aleksey Midenkov
Resolution: Fixed Votes: 0
Labels: None


 Description   

--source include/have_partition.inc
 
CREATE TABLE t (a INT) WITH SYSTEM VERSIONING PARTITION BY SYSTEM_TIME;
--delimiter $
CREATE FUNCTION f() RETURNS INT
BEGIN
  UPDATE t SET a = 1;
  RETURN 1;
END $
--delimiter ;
CREATE PROCEDURE p() SELECT f();
CALL p();
CALL p();
 
# Cleanup
DROP PROCEDURE p;
DROP FUNCTION f;
DROP TABLE t;

10.9 d8997f87

mariadbd: /data/src/10.9/sql/partition_info.cc:802: bool partition_info::vers_set_hist_part(THD*, uint*): Assertion `!thd->lex->last_table() || !thd->lex->last_table()->vers_conditions.delete_history' failed.
230511 17:30:58 [ERROR] mysqld got signal 6 ;
 
#9  0x00007f664ec53df2 in __GI___assert_fail (assertion=0x55d320585200 "!thd->lex->last_table() || !thd->lex->last_table()->vers_conditions.delete_history", file=0x55d320584220 "/data/src/10.9/sql/partition_info.cc", line=802, function=0x55d320585280 "bool partition_info::vers_set_hist_part(THD*, uint*)") at ./assert/assert.c:101
#10 0x000055d31e82a618 in partition_info::vers_set_hist_part (this=0x61d000233cb8, thd=0x62b00007e218, create_count=0x7f66475675e4) at /data/src/10.9/sql/partition_info.cc:802
#11 0x000055d31e236292 in TABLE::vers_switch_partition (this=0x619000099298, thd=0x62b00007e218, table_list=0x625000190ac0, ot_ctx=0x7f66475675b0) at /data/src/10.9/sql/sql_base.cc:1761
#12 0x000055d31e238cb7 in open_table (thd=0x62b00007e218, table_list=0x625000190ac0, ot_ctx=0x7f66475675b0) at /data/src/10.9/sql/sql_base.cc:2215
#13 0x000055d31e243896 in open_and_process_table (thd=0x62b00007e218, tables=0x625000190ac0, counter=0x7f66475676c0, flags=0, prelocking_strategy=0x7f66475677d0, has_prelocking_list=true, ot_ctx=0x7f66475675b0) at /data/src/10.9/sql/sql_base.cc:4070
#14 0x000055d31e2466b3 in open_tables (thd=0x62b00007e218, options=..., start=0x7f66475676d0, counter=0x7f66475676c0, flags=0, prelocking_strategy=0x7f66475677d0) at /data/src/10.9/sql/sql_base.cc:4595
#15 0x000055d31e24b7b8 in open_and_lock_tables (thd=0x62b00007e218, options=..., tables=0x625000190ac0, derived=true, flags=0, prelocking_strategy=0x7f66475677d0) at /data/src/10.9/sql/sql_base.cc:5569
#16 0x000055d31e1a1c90 in open_and_lock_tables (thd=0x62b00007e218, tables=0x625000190ac0, derived=true, flags=0) at /data/src/10.9/sql/sql_base.h:510
#17 0x000055d31e3ffbf3 in execute_sqlcom_select (thd=0x62b00007e218, all_tables=0x625000190ac0) at /data/src/10.9/sql/sql_parse.cc:6198
#18 0x000055d31e3eec50 in mysql_execute_command (thd=0x62b00007e218, is_called_from_prepared_stmt=false) at /data/src/10.9/sql/sql_parse.cc:3948
#19 0x000055d31e18b76d in sp_instr_stmt::exec_core (this=0x62500018cda0, thd=0x62b00007e218, nextp=0x7f6647568b90) at /data/src/10.9/sql/sp_head.cc:3857
#20 0x000055d31e189d46 in sp_lex_keeper::reset_lex_and_exec_core (this=0x62500018cde8, thd=0x62b00007e218, nextp=0x7f6647568b90, open_tables=false, instr=0x62500018cda0) at /data/src/10.9/sql/sp_head.cc:3582
#21 0x000055d31e18af00 in sp_instr_stmt::execute (this=0x62500018cda0, thd=0x62b00007e218, nextp=0x7f6647568b90) at /data/src/10.9/sql/sp_head.cc:3763
#22 0x000055d31e17b8c2 in sp_head::execute (this=0x625000188938, thd=0x62b00007e218, merge_da_on_success=true) at /data/src/10.9/sql/sp_head.cc:1459
#23 0x000055d31e181982 in sp_head::execute_procedure (this=0x625000188938, thd=0x62b00007e218, args=0x62b000083578) at /data/src/10.9/sql/sp_head.cc:2446
#24 0x000055d31e3e7df5 in do_execute_sp (thd=0x62b00007e218, sp=0x625000188938) at /data/src/10.9/sql/sql_parse.cc:3024
#25 0x000055d31e3e996a in Sql_cmd_call::execute (this=0x6290000e6308, thd=0x62b00007e218) at /data/src/10.9/sql/sql_parse.cc:3270
#26 0x000055d31e3fe1ec in mysql_execute_command (thd=0x62b00007e218, is_called_from_prepared_stmt=false) at /data/src/10.9/sql/sql_parse.cc:6014
#27 0x000055d31e40b67e in mysql_parse (thd=0x62b00007e218, rawbuf=0x6290000e6238 "CALL p()", length=8, parser_state=0x7f664756aa30) at /data/src/10.9/sql/sql_parse.cc:8043
#28 0x000055d31e3e12fe in dispatch_command (command=COM_QUERY, thd=0x62b00007e218, packet=0x629000262219 "CALL p()", packet_length=8, blocking=true) at /data/src/10.9/sql/sql_parse.cc:1894
#29 0x000055d31e3de054 in do_command (thd=0x62b00007e218, blocking=true) at /data/src/10.9/sql/sql_parse.cc:1407
#30 0x000055d31e891f3e in do_handle_one_connection (connect=0x608000002cb8, put_in_cache=true) at /data/src/10.9/sql/sql_connect.cc:1416
#31 0x000055d31e8918ff in handle_one_connection (arg=0x608000002c38) at /data/src/10.9/sql/sql_connect.cc:1318
#32 0x000055d31f49aa30 in pfs_spawn_thread (arg=0x617000005b98) at /data/src/10.9/storage/perfschema/pfs.cc:2201
#33 0x00007f664eca7fd4 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#34 0x00007f664ed285bc in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

Reproducible on 10.9+ with at least InnoDB, MyISAM, Aria.
No obvious immediate problem on a non-debug build.

The failure appeared in 10.9.1 since these two revisions (I couldn't build the first one, so not sure which of them)

commit 75ede427e429b24001fc55bb284c110875fbf85a
Author: Aleksey Midenkov
Date:   Fri May 6 10:45:17 2022 +0300
 
    MDEV-27328 Change of SYSTEM_TIME partitioning options is not possible without data copy

commit 92bfc0e8c4bb5c86359c29458d67f3e7836ec18a
Author: Aleksey Midenkov
Date:   Fri May 6 10:45:17 2022 +0300
 
    MDEV-17554 Auto-create new partition for system versioned tables with history partitioned by INTERVAL/LIMIT



 Comments   
Comment by Aleksey Midenkov [ 2023-07-19 ]

Debug build doesn't reproduce for me in d8997f87 and in latest 10.9

Comment by Elena Stepanova [ 2023-07-19 ]

Apparently it is only reproducible on ASAN builds. Sorry about it, I've never seen it happen before with debug assertion failures, so I don't check them separately on debug and ASAN builds.
With cmake . -DCMAKE_BUILD_TYPE=Debug -DWITH_ASAN=YES -DMYSQL_MAINTAINER_MODE=OFF it is still readily reproducible on the latest 10.9. Could you please try?

Comment by Aleksey Midenkov [ 2023-07-20 ]

Please review bb-10.9-midenok

Comment by Nikita Malyavin [ 2023-07-25 ]

ok to push

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