mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-34171: Memory leakage is detected on running the test versioning.partition
One of possible use cases that reproduces the memory leakage listed below: set timestamp= unix_timestamp('2000-01-01 00:00:00'); create or replace table t1 (x int) with system versioning partition by system_time interval 1 hour auto partitions 3; create table t2 (x int); create trigger tr after insert on t2 for each row update t1 set x= 11; create or replace procedure sp2() insert into t2 values (5); set timestamp= unix_timestamp('2000-01-01 04:00:00'); call sp2; set timestamp= unix_timestamp('2000-01-01 13:00:00'); call sp2; # <<=== Memory leak happens there. In case MariaDB server is built with the option -DWITH_PROTECT_STATEMENT_MEMROOT, the second execution would hit assert failure. The reason of leaking a memory is that once a new partition be created the table should be closed and re-opened. It results in calling the function extend_table_list() that indirectly invokes the function sp_add_used_routine() to add routines implicitly used by the statement that makes a new memory allocation. To fix it, don't remove routines and tables the statement implicitly depends on when a table being closed for subsequent re-opening.
This commit is contained in:
@@ -2945,7 +2945,7 @@ retry:
|
||||
Deadlock occurred during upgrade of metadata lock.
|
||||
Let us restart acquring and opening tables for LOCK TABLES.
|
||||
*/
|
||||
close_tables_for_reopen(thd, &tables, mdl_savepoint);
|
||||
close_tables_for_reopen(thd, &tables, mdl_savepoint, true);
|
||||
if (thd->open_temporary_tables(tables))
|
||||
goto err;
|
||||
goto retry;
|
||||
|
Reference in New Issue
Block a user