mirror of
https://github.com/MariaDB/server.git
synced 2025-01-18 04:53:01 +01:00
Bug#30712 (open_performance_schema_table() cause an open table leak on
failures) Fixed open_performance_schema_table() and close_performance_schema_table() implementation and callers, to always execute balanced calls to: thd->reset_n_backup_open_tables_state(backup); thd->restore_backup_open_tables_state(backup);
This commit is contained in:
parent
496eb569d9
commit
88091e8250
2 changed files with 29 additions and 19 deletions
10
sql/log.cc
10
sql/log.cc
|
@ -656,8 +656,14 @@ int Log_to_csv_event_handler::
|
|||
|
||||
table= open_performance_schema_table(thd, & table_list,
|
||||
& open_tables_backup);
|
||||
result= (table ? 0 : 1);
|
||||
close_performance_schema_table(thd, & open_tables_backup);
|
||||
if (table)
|
||||
{
|
||||
result= 0;
|
||||
close_performance_schema_table(thd, & open_tables_backup);
|
||||
}
|
||||
else
|
||||
result= 1;
|
||||
|
||||
DBUG_RETURN(result);
|
||||
}
|
||||
|
||||
|
|
|
@ -7746,6 +7746,9 @@ open_performance_schema_table(THD *thd, TABLE_LIST *one_table,
|
|||
*/
|
||||
table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET;
|
||||
}
|
||||
else
|
||||
thd->restore_backup_open_tables_state(backup);
|
||||
|
||||
thd->utime_after_lock= save_utime_after_lock;
|
||||
DBUG_RETURN(table);
|
||||
}
|
||||
|
@ -7761,24 +7764,25 @@ void close_performance_schema_table(THD *thd, Open_tables_state *backup)
|
|||
{
|
||||
bool found_old_table;
|
||||
|
||||
if (thd->lock)
|
||||
{
|
||||
/*
|
||||
Note:
|
||||
We do not create explicitly a separate transaction for the
|
||||
performance table I/O, but borrow the current transaction.
|
||||
lock + unlock will autocommit the change done in the
|
||||
performance schema table: this is the expected result.
|
||||
The current transaction should not be affected by this code.
|
||||
TODO: Note that if a transactional engine is used for log tables,
|
||||
this code will need to be revised, as a separate transaction
|
||||
might be needed.
|
||||
*/
|
||||
mysql_unlock_tables(thd, thd->lock);
|
||||
thd->lock= 0;
|
||||
}
|
||||
/*
|
||||
If open_performance_schema_table() fails,
|
||||
this function should not be called.
|
||||
*/
|
||||
DBUG_ASSERT(thd->lock != NULL);
|
||||
|
||||
safe_mutex_assert_not_owner(&LOCK_open);
|
||||
/*
|
||||
Note:
|
||||
We do not create explicitly a separate transaction for the
|
||||
performance table I/O, but borrow the current transaction.
|
||||
lock + unlock will autocommit the change done in the
|
||||
performance schema table: this is the expected result.
|
||||
The current transaction should not be affected by this code.
|
||||
TODO: Note that if a transactional engine is used for log tables,
|
||||
this code will need to be revised, as a separate transaction
|
||||
might be needed.
|
||||
*/
|
||||
mysql_unlock_tables(thd, thd->lock);
|
||||
thd->lock= 0;
|
||||
|
||||
pthread_mutex_lock(&LOCK_open);
|
||||
|
||||
|
|
Loading…
Reference in a new issue