1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +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

@ -4131,7 +4131,7 @@ int select_insert::prepare2(JOIN *)
}
void select_insert::cleanup()
void select_insert::reset_for_next_ps_execution()
{
/* select_insert/select_create are never re-used in prepared statement */
DBUG_ASSERT(0);
@ -4245,6 +4245,13 @@ bool select_insert::prepare_eof()
DBUG_PRINT("enter", ("trans_table: %d, table_type: '%s'",
trans_table, table->file->table_type()));
/****************************************************************************
NOTE: if you change here be aware that almost the same code is in
select_insert::abort_result_set().
****************************************************************************/
#ifdef WITH_WSREP
error= (thd->wsrep_cs().current_error()) ? -1 :
(thd->locked_tables_mode <= LTM_LOCK_TABLES) ?
@ -4377,6 +4384,12 @@ void select_insert::abort_result_set()
*/
if (table && table->file->is_open())
{
/****************************************************************************
NOTE: if you change here be aware that almost the same code is in
select_insert::prepare_eof().
****************************************************************************/
bool changed, transactional_table;
/*
If we are not in prelocked mode, we end the bulk insert started
@ -4404,7 +4417,14 @@ void select_insert::abort_result_set()
If table creation failed, the number of rows modified will also be
zero, so no check for that is made.
*/
changed= (info.copied || info.deleted || info.updated);
if ((changed= (info.copied || info.deleted || info.updated)))
{
/*
We must invalidate the table in the query cache before binlog writing
and ha_autocommit_or_rollback.
*/
query_cache_invalidate3(thd, table, 1);
}
transactional_table= table->file->has_transactions_and_rollback();
if (thd->transaction->stmt.modified_non_trans_table ||
thd->log_current_statement)