mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-33426: Aria temptables wrong thread-specific memory accounting in slave thread
Aria temporary tables account allocated memory as specific to the current THD. But this fails for slave threads, where the temporary tables need to be detached from any specific THD. Introduce a new flag to mark temporary tables in replication as "global", and use that inside Aria to not account memory allocations as thread specific for such tables. Based on original suggestion by Monty. Reviewed-by: Monty <monty@mariadb.org> Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
This commit is contained in:
@ -2827,6 +2827,17 @@ int handler::ha_open(TABLE *table_arg, const char *name, int mode,
|
||||
DBUG_ASSERT(alloc_root_inited(&table->mem_root));
|
||||
|
||||
set_partitions_to_open(partitions_to_open);
|
||||
internal_tmp_table= MY_TEST(test_if_locked & HA_OPEN_INTERNAL_TABLE);
|
||||
|
||||
if (!internal_tmp_table && (test_if_locked & HA_OPEN_TMP_TABLE) &&
|
||||
current_thd->slave_thread)
|
||||
{
|
||||
/*
|
||||
This is a temporary table used by replication that is not attached
|
||||
to a THD. Mark it as a global temporary table.
|
||||
*/
|
||||
test_if_locked|= HA_OPEN_GLOBAL_TMP_TABLE;
|
||||
}
|
||||
|
||||
if (unlikely((error=open(name,mode,test_if_locked))))
|
||||
{
|
||||
@ -2872,7 +2883,6 @@ int handler::ha_open(TABLE *table_arg, const char *name, int mode,
|
||||
cached_table_flags= table_flags();
|
||||
}
|
||||
reset_statistics();
|
||||
internal_tmp_table= MY_TEST(test_if_locked & HA_OPEN_INTERNAL_TABLE);
|
||||
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
@ -4857,6 +4867,9 @@ handler::ha_create(const char *name, TABLE *form, HA_CREATE_INFO *info_arg)
|
||||
{
|
||||
DBUG_ASSERT(m_lock_type == F_UNLCK);
|
||||
mark_trx_read_write();
|
||||
if ((info_arg->options & HA_LEX_CREATE_TMP_TABLE) &&
|
||||
current_thd->slave_thread)
|
||||
info_arg->options|= HA_LEX_CREATE_GLOBAL_TMP_TABLE;
|
||||
int error= create(name, form, info_arg);
|
||||
if (!error &&
|
||||
!(info_arg->options & (HA_LEX_CREATE_TMP_TABLE | HA_CREATE_TMP_ALTER)))
|
||||
|
Reference in New Issue
Block a user