summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei <andrei.elkin@mariadb.com>2022-01-18 18:09:51 +0200
committerAndrei <andrei.elkin@mariadb.com>2022-01-18 18:09:51 +0200
commit9ccd737114dbc53ada39b55e4d554758bd3f78e1 (patch)
tree4eabf5e793ed5979a202a7f8ef15322c91fc11a1
parent06e230665cc16204eeffb8c8942e10a1788e6a08 (diff)
downloadmariadb-git-9ccd737114dbc53ada39b55e4d554758bd3f78e1.tar.gz
MDEV-26887 Assertion (longlong) thd->status_var.local_memory_used >= 0
Can not apply to slave worker thread because of temporary table pool that is shared by the worker pool. A table can be opened by one thread and closed by another one, or not at all. Hence the slave worker thread has to get exempted from the assert.
-rw-r--r--sql/mysqld.cc2
-rw-r--r--sql/sql_class.cc8
2 files changed, 8 insertions, 2 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 0e6047cdec8..b57062f728f 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -3679,7 +3679,7 @@ static void my_malloc_size_cb_func(long long size, my_bool is_thread_specific)
}
}
DBUG_ASSERT((longlong) thd->status_var.local_memory_used >= 0 ||
- !debug_assert_on_not_freed_memory);
+ !debug_assert_on_not_freed_memory || thd->rgi_slave);
}
else if (likely(thd))
{
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index d3b4ead40a0..6a600f31ab4 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -1742,8 +1742,14 @@ THD::~THD()
{
DBUG_PRINT("error", ("memory_used: %lld", status_var.local_memory_used));
SAFEMALLOC_REPORT_MEMORY(thread_id);
+ /*
+ Slave applier threads do not own individual temporary tables. A table
+ can be opened by one and closed by another thread. The temporary table
+ list can be also empty at the assert point.
+ So the slave applier thread has to be exempted.
+ */
DBUG_ASSERT(status_var.local_memory_used == 0 ||
- !debug_assert_on_not_freed_memory);
+ !debug_assert_on_not_freed_memory || rgi_slave);
}
update_global_memory_status(status_var.global_memory_used);
set_current_thd(orig_thd == this ? 0 : orig_thd);