1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-05 13:16:09 +03:00

Fixed wrong assignment in calculate_block_sizes() for MEM_ROOT

The effect was that that ROOT_FLAG_THREAD_SPECIFIC was cleared and
the memory allocated by memroot would be contributed the the system,
not to the thread.

This exposed a bug in how "show explain for ..." allocated data.
- The thread that did provide the explain allocated data in the
  "show explain" threads mem_root, which is marked as THREAD_SPECIFIC.
- Fixed by allocating the explain data in a temporary explain_mem_root
  which is not THREAD_SPECIFIC.

Other things:
- Added extra checks when using update_malloc_size()
- Do not call update_malloc_size() for memory not registered with
  update_malloc_size(). This avoid some wrong 'memory not freed' reports.
- Added a checking of 'thd->killed' to ensure that
  main.truncate_notembedded.test still works.

Reported by: Yury Chaikou
This commit is contained in:
Monty
2023-06-12 20:11:32 +03:00
parent c4cf5e17ac
commit e1a631fecc
5 changed files with 54 additions and 18 deletions

View File

@@ -482,6 +482,14 @@ bool Sql_cmd_truncate_table::truncate_table(THD *thd, TABLE_LIST *table_ref)
if (lock_table(thd, table_ref, &hton_can_recreate))
DBUG_RETURN(TRUE);
/*
This is mainly here for truncate_notembedded.test, but it is still
useful to check killed after we got the lock
*/
if (thd->killed)
DBUG_RETURN(TRUE);
if (hton_can_recreate)
{
/*