Skip to content

Commit 77a2498

Browse files
committed
PS-9509 (8.0) Solved problem with memory counting by adding mysql_thread_set_psi_THD(thd) call
https://perconadev.atlassian.net/browse/PS-9509 The problem was in initialization of memory counting code, pfs_memory_alloc_vc() function file pfc.cc:8410. If no thread is assotiated to the thd, then counters ignored. So, the soulution is to add pfs_thread->m_cnt_thd by calling mysql_thread_set_psi_THD(thd) in the thread attaching code
1 parent 66b2a91 commit 77a2498

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

sql/threadpool_common.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ static bool thread_attach(THD *thd) {
108108
thd->store_globals();
109109
#ifdef HAVE_PSI_THREAD_INTERFACE
110110
PSI_THREAD_CALL(set_thread)(thd->get_psi());
111+
mysql_thread_set_psi_THD(thd);
111112
#endif
112113
mysql_socket_set_thread_owner(
113114
thd->get_protocol_classic()->get_vio()->mysql_socket);
@@ -191,6 +192,7 @@ void threadpool_remove_connection(THD *thd) {
191192

192193
#ifdef HAVE_PSI_THREAD_INTERFACE
193194
PSI_THREAD_CALL(delete_thread)(thd->get_psi());
195+
mysql_thread_set_psi_THD(nullptr);
194196
#endif
195197

196198
Global_THD_manager::get_instance()->remove_thd(thd);
@@ -251,6 +253,7 @@ int threadpool_process_request(THD *thd) {
251253
}
252254

253255
end:
256+
mysql_thread_set_psi_THD(nullptr);
254257
if (!retval && !thd->m_server_idle) {
255258
MYSQL_SOCKET_SET_STATE(thd->get_protocol_classic()->get_vio()->mysql_socket,
256259
PSI_SOCKET_STATE_IDLE);

0 commit comments

Comments
 (0)