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

MDEV-35326: Memory Leak in init_io_cache_ext upon SHUTDOWN

The problems were that:
1) resources was freed "asimetric" normal execution in send_eof,
 in case of error in destructor.
2) destructor was not called in case of SP for result objects.
(so if the last SP execution ended with error resorces was not
freeded on reinit before execution (cleanup() called before next
execution) and destructor also was not called due to lack of
delete call for the object)

Result cleanup() renamed to reset_for_next_ps_execution() to better
reflect function().

All result method revised and freeing resources made "symetric".

Destructor of result object called for SP.

Added skipped invalidation in case of error in insert.

Removed misleading naming of reset(thd) (could be mixed with
with reset()).
This commit is contained in:
Oleksandr Byelkin
2024-12-23 22:36:01 +01:00
parent f862fe8b2b
commit 0d35fe6e57
12 changed files with 162 additions and 69 deletions

View File

@ -547,7 +547,7 @@ int select_unit::delete_record()
tables of JOIN - exec_tmp_table_[1 | 2].
*/
void select_unit::cleanup()
void select_unit::reset_for_next_ps_execution()
{
table->file->extra(HA_EXTRA_RESET_STATE);
table->file->ha_delete_all_rows();
@ -902,11 +902,11 @@ bool select_unit_ext::send_eof()
return (MY_TEST(error));
}
void select_union_recursive::cleanup()
void select_union_recursive::reset_for_next_ps_execution()
{
if (table)
{
select_unit::cleanup();
select_unit::reset_for_next_ps_execution();
free_tmp_table(thd, table);
}
@ -2194,7 +2194,7 @@ bool st_select_lex_unit::exec()
if (uncacheable || !item || !item->assigned() || describe)
{
if (!fake_select_lex && !(with_element && with_element->is_recursive))
union_result->cleanup();
union_result->reset_for_next_ps_execution();
for (SELECT_LEX *sl= select_cursor; sl; sl= sl->next_select())
{
ha_rows records_at_start= 0;
@ -2636,7 +2636,7 @@ bool st_select_lex_unit::cleanup()
{
if (union_result)
{
((select_union_recursive *) union_result)->cleanup();
((select_union_recursive *) union_result)->reset_for_next_ps_execution();
delete union_result;
union_result= 0;
}