diff options
author | Vladislav Vaintroub <wlad@montyprogram.com> | 2012-11-02 10:43:52 +0100 |
---|---|---|
committer | Vladislav Vaintroub <wlad@montyprogram.com> | 2012-11-02 10:43:52 +0100 |
commit | 4ffc9c3b01459a2904a7154a6c750d128864fc7b (patch) | |
tree | d482bfdf461dc06616cfb23b61c1045a04b1b15d /sql | |
parent | 27bcea09e5230757071d27b91402647a9e0b4713 (diff) | |
download | mariadb-git-4ffc9c3b01459a2904a7154a6c750d128864fc7b.tar.gz |
MDEV-531 : Warning: Forcing close of thread ... in rpl_binlog_index
Use post_kill_notification in for one_thread_per_connection scheduler,
the same as already used in threadpool, to reliably wake a thread stuck in
read() or in different poll() variations.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/scheduler.cc | 24 | ||||
-rw-r--r-- | sql/scheduler.h | 2 | ||||
-rw-r--r-- | sql/threadpool_common.cc | 2 | ||||
-rw-r--r-- | sql/threadpool_unix.cc | 18 | ||||
-rw-r--r-- | sql/threadpool_win.cc | 16 |
5 files changed, 27 insertions, 35 deletions
diff --git a/sql/scheduler.cc b/sql/scheduler.cc index 78a1a2a32bb..0ae4121ef4c 100644 --- a/sql/scheduler.cc +++ b/sql/scheduler.cc @@ -79,11 +79,34 @@ void scheduler_init() { scheduler_wait_sync_end); } + +/** + Kill notification callback, used by one-thread-per-connection + and threadpool scheduler. + + Wakes up a thread that is stuck in read/poll/epoll/event-poll + routines used by threadpool, such that subsequent attempt to + read from client connection will result in IO error. +*/ + +void post_kill_notification(THD *thd) +{ + DBUG_ENTER("post_kill_notification"); + if (current_thd == thd || thd->system_thread) + DBUG_VOID_RETURN; + + if (thd->net.vio) + vio_shutdown(thd->net.vio, SHUT_RD); + DBUG_VOID_RETURN; +} + /* Initialize scheduler for --thread-handling=one-thread-per-connection */ #ifndef EMBEDDED_LIBRARY + + void one_thread_per_connection_scheduler(scheduler_functions *func, ulong *arg_max_connections, uint *arg_connection_count) @@ -95,6 +118,7 @@ void one_thread_per_connection_scheduler(scheduler_functions *func, func->init_new_connection_thread= init_new_connection_handler_thread; func->add_connection= create_thread_to_handle_connection; func->end_thread= one_thread_per_connection_end; + func->post_kill_notification= post_kill_notification; } #endif diff --git a/sql/scheduler.h b/sql/scheduler.h index 82bba5abe65..4e200e86d74 100644 --- a/sql/scheduler.h +++ b/sql/scheduler.h @@ -78,7 +78,7 @@ void one_thread_per_connection_scheduler(scheduler_functions *func, void one_thread_scheduler(scheduler_functions *func); extern void scheduler_init(); - +extern void post_kill_notification(THD *); /* To be used for pool-of-threads (implemeneted differently on various OSs) */ diff --git a/sql/threadpool_common.cc b/sql/threadpool_common.cc index 7e5bbd11c69..6b956768287 100644 --- a/sql/threadpool_common.cc +++ b/sql/threadpool_common.cc @@ -257,7 +257,7 @@ static scheduler_functions tp_scheduler_functions= tp_add_connection, // add_connection tp_wait_begin, // thd_wait_begin tp_wait_end, // thd_wait_end - tp_post_kill_notification, // post_kill_notification + post_kill_notification, // post_kill_notification NULL, // end_thread tp_end // end }; diff --git a/sql/threadpool_unix.cc b/sql/threadpool_unix.cc index f5ea771883d..da38d64fa4d 100644 --- a/sql/threadpool_unix.cc +++ b/sql/threadpool_unix.cc @@ -173,7 +173,6 @@ static int create_worker(thread_group_t *thread_group); static void *worker_main(void *param); static void check_stall(thread_group_t *thread_group); static void connection_abort(connection_t *connection); -void tp_post_kill_notification(THD *thd); static void set_wait_timeout(connection_t *connection); static void set_next_timeout_check(ulonglong abstime); static void print_pool_blocked_message(bool); @@ -444,7 +443,7 @@ static void timeout_check(pool_timer_t *timer) /* Wait timeout exceeded, kill connection. */ mysql_mutex_lock(&thd->LOCK_thd_data); thd->killed = KILL_CONNECTION; - tp_post_kill_notification(thd); + post_kill_notification(thd); mysql_mutex_unlock(&thd->LOCK_thd_data); } else @@ -1259,21 +1258,6 @@ static void connection_abort(connection_t *connection) /** - MySQL scheduler callback : kill connection -*/ - -void tp_post_kill_notification(THD *thd) -{ - DBUG_ENTER("tp_post_kill_notification"); - if (current_thd == thd || thd->system_thread) - DBUG_VOID_RETURN; - - if (thd->net.vio) - vio_shutdown(thd->net.vio, SHUT_RD); - DBUG_VOID_RETURN; -} - -/** MySQL scheduler callback: wait begin */ diff --git a/sql/threadpool_win.cc b/sql/threadpool_win.cc index 6359f81cd2b..72e03da2453 100644 --- a/sql/threadpool_win.cc +++ b/sql/threadpool_win.cc @@ -544,22 +544,6 @@ void tp_end(void) } } -/** - Notify pool about connection being killed. -*/ -void tp_post_kill_notification(THD *thd) -{ - if (current_thd == thd) - return; /* There is nothing to do.*/ - - if (thd->system_thread) - return; /* Will crash if we attempt to kill system thread. */ - - Vio *vio= thd->net.vio; - - vio_shutdown(vio, SD_BOTH); - -} /* Handle read completion/notification. |