diff options
author | Monty <monty@mariadb.org> | 2017-12-07 21:28:00 +0200 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2017-12-08 13:46:23 +0200 |
commit | c2118a08b144c95cd4d88a080eaa70abd49f3740 (patch) | |
tree | fd888e63678a87c194b5208a07a8cbe06a51c72d /sql/threadpool_common.cc | |
parent | 3574f9c7bc74ae1dd87b442b70929f30e6f95c8e (diff) | |
download | mariadb-git-c2118a08b144c95cd4d88a080eaa70abd49f3740.tar.gz |
Move all kill mutex protection to LOCK_thd_kill
LOCK_thd_data was used to protect both THD data and
ensure that the THD is not deleted while it was in use
This patch moves the THD delete protection to LOCK_thd_kill,
which already protects the THD for kill.
The benefits are:
- More well defined what LOCK_thd_data protects
- LOCK_thd_data usage is now much simpler and easier to verify
- Less chance of deadlocks in SHOW PROCESS LIST as there is less
chance of interactions between mutexes
- Remove not needed LOCK_thread_count from
thd_get_error_context_description()
- Fewer mutex taken for thd->awake()
Other things:
- Don't take mysys->var mutex in show processlist to check if thread
is kill marked
- thd->awake() now automatically takes the LOCK_thd_kill mutex
(Simplifies code)
- Apc uses LOCK_thd_kill instead of LOCK_thd_data
Diffstat (limited to 'sql/threadpool_common.cc')
-rw-r--r-- | sql/threadpool_common.cc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sql/threadpool_common.cc b/sql/threadpool_common.cc index 598951da406..98b2dcd1fcd 100644 --- a/sql/threadpool_common.cc +++ b/sql/threadpool_common.cc @@ -250,7 +250,7 @@ static THD* threadpool_add_connection(CONNECT *connect, void *scheduler_data) } delete connect; add_to_active_threads(thd); - thd->mysys_var= mysys_var; + thd->set_mysys_var(mysys_var); thd->event_scheduler.data= scheduler_data; /* Create new PSI thread for use with the THD. */ @@ -477,11 +477,11 @@ void tp_timeout_handler(TP_connection *c) if (c->state != TP_STATE_IDLE) return; THD *thd=c->thd; - mysql_mutex_lock(&thd->LOCK_thd_data); + mysql_mutex_lock(&thd->LOCK_thd_kill); thd->set_killed(KILL_WAIT_TIMEOUT); c->priority= TP_PRIORITY_HIGH; post_kill_notification(thd); - mysql_mutex_unlock(&thd->LOCK_thd_data); + mysql_mutex_unlock(&thd->LOCK_thd_kill); } |