Commit ecb9db4c authored by Nikita Malyavin's avatar Nikita Malyavin Committed by Sergei Golubchik

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.
parent 0695f7dd
......@@ -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;
......
......@@ -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
......
......@@ -512,7 +512,8 @@ class Cache_flip_event_log: public Event_log {
private:
void cleanup()
{
end_io_cache(&alt_buf);
close_cached_file(&log_file);
close_cached_file(&alt_buf);
Event_log::cleanup();
}
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment