summaryrefslogtreecommitdiff
path: root/sql/threadpool_common.cc
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@mariadb.com>2020-07-03 21:49:45 +0200
committerVladislav Vaintroub <wlad@mariadb.com>2020-07-04 11:53:26 +0200
commit272828a171417c2cc7b27b7e3aad18c85bb7d0be (patch)
tree993dea827655fce69cc74eb5abff5d9e8b1aaaaf /sql/threadpool_common.cc
parentd15c839c0dab4016eb425fdb109a5dd8ecd918a4 (diff)
parent7a4afad969e5cb903cdf82386398a75710f5ed80 (diff)
downloadmariadb-git-272828a171417c2cc7b27b7e3aad18c85bb7d0be.tar.gz
Merge branch '10.5' into 10.6
Diffstat (limited to 'sql/threadpool_common.cc')
-rw-r--r--sql/threadpool_common.cc30
1 files changed, 14 insertions, 16 deletions
diff --git a/sql/threadpool_common.cc b/sql/threadpool_common.cc
index ed74236fb0b..c27f42b3d62 100644
--- a/sql/threadpool_common.cc
+++ b/sql/threadpool_common.cc
@@ -64,24 +64,24 @@ static inline TP_connection *get_TP_connection(THD *thd)
/*
Worker threads contexts, and THD contexts.
=========================================
-
- Both worker threads and connections have their sets of thread local variables
- At the moment it is mysys_var (this has specific data for dbug, my_error and
+
+ Both worker threads and connections have their sets of thread local variables
+ At the moment it is mysys_var (this has specific data for dbug, my_error and
similar goodies), and PSI per-client structure.
Whenever query is executed following needs to be done:
1. Save worker thread context.
2. Change TLS variables to connection specific ones using thread_attach(THD*).
- This function does some additional work , e.g setting up
+ This function does some additional work , e.g setting up
thread_stack/thread_ends_here pointers.
3. Process query
4. Restore worker thread context.
- Connection login and termination follows similar schema w.r.t saving and
- restoring contexts.
+ Connection login and termination follows similar schema w.r.t saving and
+ restoring contexts.
- For both worker thread, and for the connection, mysys variables are created
+ For both worker thread, and for the connection, mysys variables are created
using my_thread_init() and freed with my_thread_end().
*/
@@ -158,7 +158,7 @@ static void thread_attach(THD* thd)
}
/*
- Determine connection priority , using current
+ Determine connection priority , using current
transaction state and 'threadpool_priority' variable value.
*/
static TP_PRIORITY get_priority(TP_connection *c)
@@ -166,7 +166,7 @@ static TP_PRIORITY get_priority(TP_connection *c)
DBUG_ASSERT(c->thd == current_thd);
TP_PRIORITY prio= (TP_PRIORITY)c->thd->variables.threadpool_priority;
if (prio == TP_PRIORITY_AUTO)
- prio= c->thd->transaction.is_active() ? TP_PRIORITY_HIGH : TP_PRIORITY_LOW;
+ prio= c->thd->transaction->is_active() ? TP_PRIORITY_HIGH : TP_PRIORITY_LOW;
return prio;
}
@@ -215,12 +215,11 @@ void tp_callback(TP_connection *c)
error:
c->thd= 0;
- delete c;
-
if (thd)
{
threadpool_remove_connection(thd);
}
+ delete c;
worker_context.restore();
}
@@ -248,9 +247,9 @@ static THD *threadpool_add_connection(CONNECT *connect, TP_connection *c)
}
delete connect;
+ thd->event_scheduler.data= c;
server_threads.insert(thd);
thd->set_mysys_var(mysys_var);
- thd->event_scheduler.data = c;
/* Login. */
thread_attach(thd);
@@ -287,7 +286,6 @@ end:
static void threadpool_remove_connection(THD *thd)
{
thread_attach(thd);
- thd->event_scheduler.data= 0;
thd->net.reading_or_writing = 0;
end_connection(thd);
close_connection(thd, 0);
@@ -296,7 +294,7 @@ static void threadpool_remove_connection(THD *thd)
delete thd;
/*
- Free resources associated with this connection:
+ Free resources associated with this connection:
mysys thread_var and PSI thread.
*/
my_thread_end();
@@ -330,8 +328,8 @@ static int threadpool_process_request(THD *thd)
if (thd->killed >= KILL_CONNECTION)
{
- /*
- killed flag was set by timeout handler
+ /*
+ killed flag was set by timeout handler
or KILL command. Return error.
*/
retval= 1;