1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-30949 Direct leak in binlog_online_alter_end_trans

when committing a big transaction, online_alter_cache_log creates a cache
file. It wasn't properly closed, which was spotted by a memory leak from
my_register_filename. A temporary file also remained open.

Binlog wasn't affected by this, since it features its own file management.

A proper closing is calling close_cached_file. It deinits io_cache and
closes the underlying file. After closing, the file is expected to be
deleted automagically.
This commit is contained in:
Nikita Malyavin
2023-04-18 00:52:46 +03:00
committed by Sergei Golubchik
parent 0695f7dd7b
commit ecb9db4c3d
3 changed files with 42 additions and 1 deletions

View File

@ -1296,6 +1296,22 @@ connection default;
select * from t;
a b c
drop table t;
#
# MDEV-30949 Direct leak in binlog_online_alter_end_trans
#
create table t (f longblob default null) engine=myisam;
insert into t values (null);
set debug_sync= "alter_table_copy_end signal copy wait_for goon";
set debug_sync= "alter_table_online_before_lock signal lock wait_for end";
alter table t force, algorithm=copy;
connection con1;
set debug_sync= "now wait_for copy";
insert into t select repeat('a',130000);
set debug_sync= "now signal goon wait_for lock";
insert into t select repeat('a',130000);
set debug_sync= "now signal end";
connection default;
drop table t;
set debug_sync= reset;
disconnect con1;
disconnect con2;

View File

@ -1475,6 +1475,30 @@ dec $i;
let local_engine=aria;
}
--echo #
--echo # MDEV-30949 Direct leak in binlog_online_alter_end_trans
--echo #
create table t (f longblob default null) engine=myisam;
insert into t values (null);
set debug_sync= "alter_table_copy_end signal copy wait_for goon";
set debug_sync= "alter_table_online_before_lock signal lock wait_for end";
send alter table t force, algorithm=copy;
--connection con1
set debug_sync= "now wait_for copy";
insert into t select repeat('a',130000);
set debug_sync= "now signal goon wait_for lock";
insert into t select repeat('a',130000);
set debug_sync= "now signal end";
--connection default
--reap
drop table t;
set debug_sync= reset;
--disconnect con1
--disconnect con2

View File

@ -512,7 +512,8 @@ public:
private:
void cleanup()
{
end_io_cache(&alt_buf);
close_cached_file(&log_file);
close_cached_file(&alt_buf);
Event_log::cleanup();
}
};