Commit 7180afa0 authored by Sergei Golubchik's avatar Sergei Golubchik

fix perfschema for pool-of-threads

parent a9b8131d
[pot]
thread_handling=pool-of-threads
[1tpc]
thread_handling=one-thread-per-connection
# run with and without threadpool
if (`SELECT count(*) FROM information_schema.GLOBAL_VARIABLES WHERE if (`SELECT count(*) FROM information_schema.GLOBAL_VARIABLES WHERE
VARIABLE_NAME = 'THREAD_HANDLING' AND VARIABLE_NAME = 'THREAD_HANDLING' AND VARIABLE_VALUE = 'pool-of-threads'`){
VARIABLE_VALUE = 'loaded-dynamically'`){
skip Test requires: 'not_threadpool'; skip Test requires: 'not_threadpool';
} }
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
--source include/have_innodb.inc --source include/have_innodb.inc
--source include/not_embedded.inc --source include/not_embedded.inc
--source include/no_protocol.inc --source include/no_protocol.inc
--source include/maybe_pool_of_threads.inc
--enable_connect_log --enable_connect_log
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
--source include/not_embedded.inc --source include/not_embedded.inc
--source include/have_perfschema.inc --source include/have_perfschema.inc
--source include/not_threadpool.inc
# #
# Important note: # Important note:
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
--source include/not_embedded.inc --source include/not_embedded.inc
--source include/have_innodb.inc --source include/have_innodb.inc
--source include/no_protocol.inc --source include/no_protocol.inc
--source include/maybe_pool_of_threads.inc
--disable_query_log --disable_query_log
--source ../include/transaction_setup.inc --source ../include/transaction_setup.inc
--enable_query_log --enable_query_log
......
...@@ -82,17 +82,6 @@ extern void post_kill_notification(THD *); ...@@ -82,17 +82,6 @@ extern void post_kill_notification(THD *);
struct thd_scheduler struct thd_scheduler
{ {
public: public:
/*
Thread instrumentation for the user job.
This member holds the instrumentation while the user job is not run
by a thread.
Note that this member is not conditionally declared
(ifdef HAVE_PSI_INTERFACE), because doing so will change the binary
layout of THD, which is exposed to plugin code that may be compiled
differently.
*/
PSI_thread *m_psi;
void *data; /* scheduler-specific data structure */ void *data; /* scheduler-specific data structure */
}; };
......
...@@ -758,7 +758,6 @@ THD::THD(my_thread_id id, bool is_wsrep_applier) ...@@ -758,7 +758,6 @@ THD::THD(my_thread_id id, bool is_wsrep_applier)
thread_stack= 0; thread_stack= 0;
scheduler= thread_scheduler; // Will be fixed later scheduler= thread_scheduler; // Will be fixed later
event_scheduler.data= 0; event_scheduler.data= 0;
event_scheduler.m_psi= 0;
skip_wait_timeout= false; skip_wait_timeout= false;
catalog= (char*)"std"; // the only catalog we have for now catalog= (char*)"std"; // the only catalog we have for now
main_security_ctx.init(); main_security_ctx.init();
......
...@@ -151,7 +151,7 @@ static void thread_attach(THD* thd) ...@@ -151,7 +151,7 @@ static void thread_attach(THD* thd)
pthread_setspecific(THR_KEY_mysys,thd->mysys_var); pthread_setspecific(THR_KEY_mysys,thd->mysys_var);
thd->thread_stack=(char*)&thd; thd->thread_stack=(char*)&thd;
thd->store_globals(); thd->store_globals();
PSI_CALL_set_thread(thd->event_scheduler.m_psi); PSI_CALL_set_thread(thd->get_psi());
mysql_socket_set_thread_owner(thd->net.vio->mysql_socket); mysql_socket_set_thread_owner(thd->net.vio->mysql_socket);
} }
...@@ -235,21 +235,13 @@ static THD* threadpool_add_connection(CONNECT *connect, void *scheduler_data) ...@@ -235,21 +235,13 @@ static THD* threadpool_add_connection(CONNECT *connect, void *scheduler_data)
pthread_setspecific(THR_KEY_mysys, 0); pthread_setspecific(THR_KEY_mysys, 0);
my_thread_init(); my_thread_init();
st_my_thread_var* mysys_var= (st_my_thread_var *)pthread_getspecific(THR_KEY_mysys); st_my_thread_var* mysys_var= (st_my_thread_var *)pthread_getspecific(THR_KEY_mysys);
PSI_CALL_set_thread(PSI_CALL_new_thread(key_thread_one_connection, connect, 0));
if (!mysys_var ||!(thd= connect->create_thd(NULL))) if (!mysys_var ||!(thd= connect->create_thd(NULL)))
{ {
/* Out of memory? */ /* Out of memory? */
connect->close_and_delete(); connect->close_and_delete();
if (mysys_var) if (mysys_var)
{
#ifdef HAVE_PSI_INTERFACE
/*
current PSI is still from worker thread.
Set to 0, to avoid premature cleanup by my_thread_end
*/
if (PSI_server) PSI_server->set_thread(0);
#endif
my_thread_end(); my_thread_end();
}
return NULL; return NULL;
} }
delete connect; delete connect;
...@@ -257,11 +249,6 @@ static THD* threadpool_add_connection(CONNECT *connect, void *scheduler_data) ...@@ -257,11 +249,6 @@ static THD* threadpool_add_connection(CONNECT *connect, void *scheduler_data)
thd->set_mysys_var(mysys_var); thd->set_mysys_var(mysys_var);
thd->event_scheduler.data= scheduler_data; thd->event_scheduler.data= scheduler_data;
/* Create new PSI thread for use with the THD. */
thd->event_scheduler.m_psi=
PSI_CALL_new_thread(key_thread_one_connection, thd, thd->thread_id);
/* Login. */ /* Login. */
thread_attach(thd); thread_attach(thd);
re_init_net_server_extension(thd); re_init_net_server_extension(thd);
...@@ -301,6 +288,7 @@ static void threadpool_remove_connection(THD *thd) ...@@ -301,6 +288,7 @@ static void threadpool_remove_connection(THD *thd)
end_connection(thd); end_connection(thd);
close_connection(thd, 0); close_connection(thd, 0);
unlink_thd(thd); unlink_thd(thd);
PSI_CALL_delete_current_thread(); // before THD is destroyed
delete thd; delete thd;
/* /*
......
...@@ -2168,7 +2168,6 @@ extern "C" void* pfs_spawn_thread(void *arg) ...@@ -2168,7 +2168,6 @@ extern "C" void* pfs_spawn_thread(void *arg)
pfs= create_thread(klass, typed_arg->m_child_identity, 0); pfs= create_thread(klass, typed_arg->m_child_identity, 0);
if (likely(pfs != NULL)) if (likely(pfs != NULL))
{ {
pfs->m_thread_os_id= my_thread_os_id();
clear_thread_account(pfs); clear_thread_account(pfs);
pfs->m_parent_thread_internal_id= typed_arg->m_thread_internal_id; pfs->m_parent_thread_internal_id= typed_arg->m_thread_internal_id;
...@@ -2267,7 +2266,15 @@ pfs_new_thread_v1(PSI_thread_key key, const void *identity, ulonglong processlis ...@@ -2267,7 +2266,15 @@ pfs_new_thread_v1(PSI_thread_key key, const void *identity, ulonglong processlis
PFS_thread_class *klass= find_thread_class(key); PFS_thread_class *klass= find_thread_class(key);
if (likely(klass != NULL)) if (likely(klass != NULL))
{
pfs= create_thread(klass, identity, processlist_id); pfs= create_thread(klass, identity, processlist_id);
if (pfs != NULL)
{
PFS_thread *parent= my_thread_get_THR_PFS();
if (parent != NULL)
pfs->m_parent_thread_internal_id= parent->m_parent_thread_internal_id;
}
}
else else
pfs= NULL; pfs= NULL;
......
...@@ -529,7 +529,7 @@ PFS_thread* create_thread(PFS_thread_class *klass, const void *identity, ...@@ -529,7 +529,7 @@ PFS_thread* create_thread(PFS_thread_class *klass, const void *identity,
PFS_atomic::add_u64(&thread_internal_id_counter.m_u64, 1); PFS_atomic::add_u64(&thread_internal_id_counter.m_u64, 1);
pfs->m_parent_thread_internal_id= 0; pfs->m_parent_thread_internal_id= 0;
pfs->m_processlist_id= static_cast<ulong>(processlist_id); pfs->m_processlist_id= static_cast<ulong>(processlist_id);
pfs->m_thread_os_id= 0; pfs->m_thread_os_id= my_thread_os_id();
pfs->m_event_id= 1; pfs->m_event_id= 1;
pfs->m_stmt_lock.set_allocated(); pfs->m_stmt_lock.set_allocated();
pfs->m_session_lock.set_allocated(); pfs->m_session_lock.set_allocated();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment