Commit 6900aaf4 authored by Sergey Vojtovich's avatar Sergey Vojtovich

Simplified away init_new_connection_thread()

It was meaningful only for one-thread-per-connection scheduler anyway,
so call init_new_connection_handler_thread() directly from
handle_one_connection().

It was somewhat harmful for no-threads scheduler, because it'd attempt to
detach main thread on AIX_3_2 and Siemens unix (and DEC OSF/1 3.2 too).
Also it does duplicate my_thread_init() call, which may produce a warning
under EXTRA_DEBUG_THREADS.

start_wsrep_THD() shouldn't have called it at all: it already detached
and called my_thread_init().

Part of MDEV-19515 - Improve connect speed
parent 8d9d4aa6
...@@ -82,8 +82,6 @@ bool do_command(THD *thd); ...@@ -82,8 +82,6 @@ bool do_command(THD *thd);
ensure that the proper MySQL Server logic attached to these events is ensure that the proper MySQL Server logic attached to these events is
executed. executed.
*/ */
/* Initialise a new connection handler thread */
bool init_new_connection_handler_thread();
/* Set up connection thread before use as execution thread */ /* Set up connection thread before use as execution thread */
bool setup_connection_thread_globals(THD *thd); bool setup_connection_thread_globals(THD *thd);
/* Prepare connection as part of connection set-up */ /* Prepare connection as part of connection set-up */
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include "mariadb.h" #include "mariadb.h"
#include "mysqld.h" #include "mysqld.h"
#include "sql_connect.h" // init_new_connection_handler_thread
#include "scheduler.h" #include "scheduler.h"
#include "sql_class.h" #include "sql_class.h"
#include "sql_callback.h" #include "sql_callback.h"
...@@ -133,16 +132,11 @@ void one_thread_per_connection_scheduler(scheduler_functions *func, ...@@ -133,16 +132,11 @@ void one_thread_per_connection_scheduler(scheduler_functions *func,
func->max_threads= *arg_max_connections + 1; func->max_threads= *arg_max_connections + 1;
func->max_connections= arg_max_connections; func->max_connections= arg_max_connections;
func->connection_count= arg_connection_count; func->connection_count= arg_connection_count;
func->init_new_connection_thread= init_new_connection_handler_thread;
func->add_connection= create_thread_to_handle_connection; func->add_connection= create_thread_to_handle_connection;
func->end_thread= one_thread_per_connection_end; func->end_thread= one_thread_per_connection_end;
func->post_kill_notification= post_kill_notification; func->post_kill_notification= post_kill_notification;
} }
#else #else
bool init_new_connection_handler_thread()
{
return 0;
}
void handle_connection_in_main_thread(CONNECT *connect) void handle_connection_in_main_thread(CONNECT *connect)
{ {
} }
...@@ -158,7 +152,6 @@ void one_thread_scheduler(scheduler_functions *func) ...@@ -158,7 +152,6 @@ void one_thread_scheduler(scheduler_functions *func)
func->max_threads= 1; func->max_threads= 1;
func->max_connections= &max_connections; func->max_connections= &max_connections;
func->connection_count= &connection_count; func->connection_count= &connection_count;
func->init_new_connection_thread= init_new_connection_handler_thread;
func->add_connection= handle_connection_in_main_thread; func->add_connection= handle_connection_in_main_thread;
func->end_thread= no_threads_end; func->end_thread= no_threads_end;
} }
...@@ -34,7 +34,6 @@ struct scheduler_functions ...@@ -34,7 +34,6 @@ struct scheduler_functions
uint max_threads, *connection_count; uint max_threads, *connection_count;
ulong *max_connections; ulong *max_connections;
bool (*init)(void); bool (*init)(void);
bool (*init_new_connection_thread)(void);
void (*add_connection)(CONNECT *connect); void (*add_connection)(CONNECT *connect);
void (*thd_wait_begin)(THD *thd, int wait_type); void (*thd_wait_begin)(THD *thd, int wait_type);
void (*thd_wait_end)(THD *thd); void (*thd_wait_end)(THD *thd);
......
...@@ -1303,6 +1303,14 @@ pthread_handler_t handle_one_connection(void *arg) ...@@ -1303,6 +1303,14 @@ pthread_handler_t handle_one_connection(void *arg)
mysql_thread_set_psi_id(connect->thread_id); mysql_thread_set_psi_id(connect->thread_id);
if (init_new_connection_handler_thread())
{
scheduler_functions *scheduler= connect->scheduler;
connect->close_with_error(0, 0, ER_OUT_OF_RESOURCES);
scheduler->end_thread(0, 0);
return 0;
}
do_handle_one_connection(connect); do_handle_one_connection(connect);
return 0; return 0;
} }
...@@ -1340,8 +1348,7 @@ void do_handle_one_connection(CONNECT *connect) ...@@ -1340,8 +1348,7 @@ void do_handle_one_connection(CONNECT *connect)
{ {
ulonglong thr_create_utime= microsecond_interval_timer(); ulonglong thr_create_utime= microsecond_interval_timer();
THD *thd; THD *thd;
if (connect->scheduler->init_new_connection_thread() || if (!(thd= connect->create_thd(NULL)))
!(thd= connect->create_thd(NULL)))
{ {
scheduler_functions *scheduler= connect->scheduler; scheduler_functions *scheduler= connect->scheduler;
connect->close_with_error(0, 0, ER_OUT_OF_RESOURCES); connect->close_with_error(0, 0, ER_OUT_OF_RESOURCES);
......
...@@ -383,11 +383,6 @@ static int threadpool_process_request(THD *thd) ...@@ -383,11 +383,6 @@ static int threadpool_process_request(THD *thd)
/* Dummy functions, do nothing */ /* Dummy functions, do nothing */
static bool tp_init_new_connection_thread()
{
return 0;
}
static bool tp_end_thread(THD *, bool) static bool tp_end_thread(THD *, bool)
{ {
return 0; return 0;
...@@ -512,7 +507,6 @@ static scheduler_functions tp_scheduler_functions= ...@@ -512,7 +507,6 @@ static scheduler_functions tp_scheduler_functions=
NULL, NULL,
NULL, NULL,
tp_init, // init tp_init, // init
tp_init_new_connection_thread, // init_new_connection_thread
tp_add_connection, // add_connection tp_add_connection, // add_connection
tp_wait_begin, // thd_wait_begin tp_wait_begin, // thd_wait_begin
tp_wait_end, // thd_wait_end tp_wait_end, // thd_wait_end
......
...@@ -2619,13 +2619,6 @@ void* start_wsrep_THD(void *arg) ...@@ -2619,13 +2619,6 @@ void* start_wsrep_THD(void *arg)
mysql_thread_set_psi_id(thd->thread_id); mysql_thread_set_psi_id(thd->thread_id);
thd->thr_create_utime= microsecond_interval_timer(); thd->thr_create_utime= microsecond_interval_timer();
if (MYSQL_CALLBACK_ELSE(thread_scheduler, init_new_connection_thread, (), 0))
{
close_connection(thd, ER_OUT_OF_RESOURCES);
statistic_increment(aborted_connects,&LOCK_status);
MYSQL_CALLBACK(thread_scheduler, end_thread, (thd, 0));
goto error;
}
// </5.1.17> // </5.1.17>
/* /*
......
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