|
|
@ -64,7 +64,9 @@ |
|
|
#include "events.h"
|
|
|
#include "events.h"
|
|
|
#include "sql_audit.h"
|
|
|
#include "sql_audit.h"
|
|
|
#include "probes_mysql.h"
|
|
|
#include "probes_mysql.h"
|
|
|
|
|
|
#include "scheduler.h"
|
|
|
#include "debug_sync.h"
|
|
|
#include "debug_sync.h"
|
|
|
|
|
|
#include "sql_callback.h"
|
|
|
|
|
|
|
|
|
#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
|
|
|
#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
|
|
|
#include "../storage/perfschema/pfs_server.h"
|
|
|
#include "../storage/perfschema/pfs_server.h"
|
|
|
@ -193,6 +195,9 @@ typedef fp_except fp_except_t; |
|
|
# endif
|
|
|
# endif
|
|
|
#endif
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
extern "C" my_bool reopen_fstreams(const char *filename, |
|
|
|
|
|
FILE *outstream, FILE *errstream); |
|
|
|
|
|
|
|
|
inline void setup_fpu() |
|
|
inline void setup_fpu() |
|
|
{ |
|
|
{ |
|
|
#if defined(__FreeBSD__) && defined(HAVE_IEEEFP_H)
|
|
|
#if defined(__FreeBSD__) && defined(HAVE_IEEEFP_H)
|
|
|
@ -456,7 +461,7 @@ ulong slave_trans_retries; |
|
|
uint slave_net_timeout; |
|
|
uint slave_net_timeout; |
|
|
ulong slave_exec_mode_options; |
|
|
ulong slave_exec_mode_options; |
|
|
ulonglong slave_type_conversions_options; |
|
|
ulonglong slave_type_conversions_options; |
|
|
ulong thread_cache_size=0, thread_pool_size= 0; |
|
|
|
|
|
|
|
|
ulong thread_cache_size=0; |
|
|
ulong binlog_cache_size=0; |
|
|
ulong binlog_cache_size=0; |
|
|
ulonglong max_binlog_cache_size=0; |
|
|
ulonglong max_binlog_cache_size=0; |
|
|
ulong query_cache_size=0; |
|
|
ulong query_cache_size=0; |
|
|
@ -898,8 +903,6 @@ my_bool opt_enable_shared_memory; |
|
|
HANDLE smem_event_connect_request= 0; |
|
|
HANDLE smem_event_connect_request= 0; |
|
|
#endif
|
|
|
#endif
|
|
|
|
|
|
|
|
|
scheduler_functions thread_scheduler; |
|
|
|
|
|
|
|
|
|
|
|
my_bool opt_use_ssl = 0; |
|
|
my_bool opt_use_ssl = 0; |
|
|
char *opt_ssl_ca= NULL, *opt_ssl_capath= NULL, *opt_ssl_cert= NULL, |
|
|
char *opt_ssl_ca= NULL, *opt_ssl_capath= NULL, *opt_ssl_cert= NULL, |
|
|
*opt_ssl_cipher= NULL, *opt_ssl_key= NULL; |
|
|
*opt_ssl_cipher= NULL, *opt_ssl_key= NULL; |
|
|
@ -1087,7 +1090,8 @@ static void close_connections(void) |
|
|
continue; |
|
|
continue; |
|
|
|
|
|
|
|
|
tmp->killed= THD::KILL_CONNECTION; |
|
|
tmp->killed= THD::KILL_CONNECTION; |
|
|
thread_scheduler.post_kill_notification(tmp); |
|
|
|
|
|
|
|
|
MYSQL_CALLBACK(thread_scheduler, post_kill_notification, (tmp)); |
|
|
|
|
|
mysql_mutex_lock(&tmp->LOCK_thd_data); |
|
|
if (tmp->mysys_var) |
|
|
if (tmp->mysys_var) |
|
|
{ |
|
|
{ |
|
|
tmp->mysys_var->abort=1; |
|
|
tmp->mysys_var->abort=1; |
|
|
@ -1100,6 +1104,7 @@ static void close_connections(void) |
|
|
} |
|
|
} |
|
|
mysql_mutex_unlock(&tmp->mysys_var->mutex); |
|
|
mysql_mutex_unlock(&tmp->mysys_var->mutex); |
|
|
} |
|
|
} |
|
|
|
|
|
mysql_mutex_unlock(&tmp->LOCK_thd_data); |
|
|
} |
|
|
} |
|
|
mysql_mutex_unlock(&LOCK_thread_count); // For unlink from list
|
|
|
mysql_mutex_unlock(&LOCK_thread_count); // For unlink from list
|
|
|
|
|
|
|
|
|
@ -1479,7 +1484,7 @@ void clean_up(bool print_message) |
|
|
if (print_message && my_default_lc_messages && server_start_time) |
|
|
if (print_message && my_default_lc_messages && server_start_time) |
|
|
sql_print_information(ER_DEFAULT(ER_SHUTDOWN_COMPLETE),my_progname); |
|
|
sql_print_information(ER_DEFAULT(ER_SHUTDOWN_COMPLETE),my_progname); |
|
|
cleanup_errmsgs(); |
|
|
cleanup_errmsgs(); |
|
|
thread_scheduler.end(); |
|
|
|
|
|
|
|
|
MYSQL_CALLBACK(thread_scheduler, end, ()); |
|
|
finish_client_errs(); |
|
|
finish_client_errs(); |
|
|
DBUG_PRINT("quit", ("Error messages freed")); |
|
|
DBUG_PRINT("quit", ("Error messages freed")); |
|
|
/* Tell main we are ready */ |
|
|
/* Tell main we are ready */ |
|
|
@ -1752,7 +1757,7 @@ static void network_init(void) |
|
|
DBUG_ENTER("network_init"); |
|
|
DBUG_ENTER("network_init"); |
|
|
LINT_INIT(ret); |
|
|
LINT_INIT(ret); |
|
|
|
|
|
|
|
|
if (thread_scheduler.init()) |
|
|
|
|
|
|
|
|
if (MYSQL_CALLBACK_ELSE(thread_scheduler, init, (), 0)) |
|
|
unireg_abort(1); /* purecov: inspected */ |
|
|
unireg_abort(1); /* purecov: inspected */ |
|
|
|
|
|
|
|
|
set_ports(); |
|
|
set_ports(); |
|
|
@ -2000,7 +2005,7 @@ extern "C" sig_handler end_thread_signal(int sig __attribute__((unused))) |
|
|
if (thd && ! thd->bootstrap) |
|
|
if (thd && ! thd->bootstrap) |
|
|
{ |
|
|
{ |
|
|
statistic_increment(killed_threads, &LOCK_status); |
|
|
statistic_increment(killed_threads, &LOCK_status); |
|
|
thread_scheduler.end_thread(thd,0); /* purecov: inspected */ |
|
|
|
|
|
|
|
|
MYSQL_CALLBACK(thread_scheduler, end_thread, (thd,0)); /* purecov: inspected */ |
|
|
} |
|
|
} |
|
|
DBUG_VOID_RETURN; /* purecov: deadcode */ |
|
|
DBUG_VOID_RETURN; /* purecov: deadcode */ |
|
|
} |
|
|
} |
|
|
@ -2396,7 +2401,7 @@ and this may fail.\n\n"); |
|
|
(ulong) dflt_key_cache->key_cache_mem_size); |
|
|
(ulong) dflt_key_cache->key_cache_mem_size); |
|
|
fprintf(stderr, "read_buffer_size=%ld\n", (long) global_system_variables.read_buff_size); |
|
|
fprintf(stderr, "read_buffer_size=%ld\n", (long) global_system_variables.read_buff_size); |
|
|
fprintf(stderr, "max_used_connections=%lu\n", max_used_connections); |
|
|
fprintf(stderr, "max_used_connections=%lu\n", max_used_connections); |
|
|
fprintf(stderr, "max_threads=%u\n", thread_scheduler.max_threads); |
|
|
|
|
|
|
|
|
fprintf(stderr, "max_threads=%u\n", thread_scheduler->max_threads); |
|
|
fprintf(stderr, "thread_count=%u\n", thread_count); |
|
|
fprintf(stderr, "thread_count=%u\n", thread_count); |
|
|
fprintf(stderr, "connection_count=%u\n", connection_count); |
|
|
fprintf(stderr, "connection_count=%u\n", connection_count); |
|
|
fprintf(stderr, "It is possible that mysqld could use up to \n\
|
|
|
fprintf(stderr, "It is possible that mysqld could use up to \n\
|
|
|
@ -2404,7 +2409,7 @@ key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = %lu K\n\ |
|
|
bytes of memory\n", ((ulong) dflt_key_cache->key_cache_mem_size + |
|
|
bytes of memory\n", ((ulong) dflt_key_cache->key_cache_mem_size + |
|
|
(global_system_variables.read_buff_size + |
|
|
(global_system_variables.read_buff_size + |
|
|
global_system_variables.sortbuff_size) * |
|
|
global_system_variables.sortbuff_size) * |
|
|
thread_scheduler.max_threads + |
|
|
|
|
|
|
|
|
thread_scheduler->max_threads + |
|
|
max_connections * sizeof(THD)) / 1024); |
|
|
max_connections * sizeof(THD)) / 1024); |
|
|
fprintf(stderr, "Hope that's ok; if not, decrease some variables in the equation.\n\n"); |
|
|
fprintf(stderr, "Hope that's ok; if not, decrease some variables in the equation.\n\n"); |
|
|
|
|
|
|
|
|
@ -2651,7 +2656,7 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused))) |
|
|
This should actually be '+ max_number_of_slaves' instead of +10, |
|
|
This should actually be '+ max_number_of_slaves' instead of +10, |
|
|
but the +10 should be quite safe. |
|
|
but the +10 should be quite safe. |
|
|
*/ |
|
|
*/ |
|
|
init_thr_alarm(thread_scheduler.max_threads + |
|
|
|
|
|
|
|
|
init_thr_alarm(thread_scheduler->max_threads + |
|
|
global_system_variables.max_insert_delayed_threads + 10); |
|
|
global_system_variables.max_insert_delayed_threads + 10); |
|
|
if (thd_lib_detected != THD_LIB_LT && (test_flags & TEST_SIGINT)) |
|
|
if (thd_lib_detected != THD_LIB_LT && (test_flags & TEST_SIGINT)) |
|
|
{ |
|
|
{ |
|
|
@ -3738,15 +3743,17 @@ static int init_server_components() |
|
|
opt_error_log= 0; // Too long file name
|
|
|
opt_error_log= 0; // Too long file name
|
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
|
|
|
my_bool res; |
|
|
#ifndef EMBEDDED_LIBRARY
|
|
|
#ifndef EMBEDDED_LIBRARY
|
|
|
if (freopen(log_error_file, "a+", stdout)) |
|
|
|
|
|
|
|
|
res= reopen_fstreams(log_error_file, stdout, stderr); |
|
|
|
|
|
#else
|
|
|
|
|
|
res= reopen_fstreams(log_error_file, NULL, stderr); |
|
|
#endif
|
|
|
#endif
|
|
|
{ |
|
|
|
|
|
if (freopen(log_error_file, "a+", stderr)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!res) |
|
|
setbuf(stderr, NULL); |
|
|
setbuf(stderr, NULL); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
proc_info_hook= set_thd_proc_info; |
|
|
proc_info_hook= set_thd_proc_info; |
|
|
|
|
|
|
|
|
@ -4353,23 +4360,6 @@ int mysqld_main(int argc, char **argv) |
|
|
} |
|
|
} |
|
|
#endif
|
|
|
#endif
|
|
|
|
|
|
|
|
|
#ifdef __WIN__
|
|
|
|
|
|
/*
|
|
|
|
|
|
Before performing any socket operation (like retrieving hostname |
|
|
|
|
|
in init_common_variables we have to call WSAStartup |
|
|
|
|
|
*/ |
|
|
|
|
|
{ |
|
|
|
|
|
WSADATA WsaData; |
|
|
|
|
|
if (SOCKET_ERROR == WSAStartup (0x0101, &WsaData)) |
|
|
|
|
|
{ |
|
|
|
|
|
/* errors are not read yet, so we use english text here */ |
|
|
|
|
|
my_message(ER_WSAS_FAILED, "WSAStartup Failed", MYF(0)); |
|
|
|
|
|
/* Not enough initializations for unireg_abort() */ |
|
|
|
|
|
return 1; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
#endif /* __WIN__ */
|
|
|
|
|
|
|
|
|
|
|
|
if (init_common_variables()) |
|
|
if (init_common_variables()) |
|
|
unireg_abort(1); // Will do exit
|
|
|
unireg_abort(1); // Will do exit
|
|
|
|
|
|
|
|
|
@ -4457,8 +4447,8 @@ int mysqld_main(int argc, char **argv) |
|
|
#ifdef __WIN__
|
|
|
#ifdef __WIN__
|
|
|
if (!opt_console) |
|
|
if (!opt_console) |
|
|
{ |
|
|
{ |
|
|
freopen(log_error_file,"a+",stdout); |
|
|
|
|
|
freopen(log_error_file,"a+",stderr); |
|
|
|
|
|
|
|
|
if (reopen_fstreams(log_error_file, stdout, stderr)) |
|
|
|
|
|
unireg_abort(1); |
|
|
setbuf(stderr, NULL); |
|
|
setbuf(stderr, NULL); |
|
|
FreeConsole(); // Remove window
|
|
|
FreeConsole(); // Remove window
|
|
|
} |
|
|
} |
|
|
@ -5028,7 +5018,7 @@ static void create_new_thread(THD *thd) |
|
|
|
|
|
|
|
|
thread_count++; |
|
|
thread_count++; |
|
|
|
|
|
|
|
|
thread_scheduler.add_connection(thd); |
|
|
|
|
|
|
|
|
MYSQL_CALLBACK(thread_scheduler, add_connection, (thd)); |
|
|
|
|
|
|
|
|
DBUG_VOID_RETURN; |
|
|
DBUG_VOID_RETURN; |
|
|
} |
|
|
} |
|
|
@ -7344,14 +7334,12 @@ static int get_options(int *argc_ptr, char ***argv_ptr) |
|
|
return 1; |
|
|
return 1; |
|
|
|
|
|
|
|
|
#ifdef EMBEDDED_LIBRARY
|
|
|
#ifdef EMBEDDED_LIBRARY
|
|
|
one_thread_scheduler(&thread_scheduler); |
|
|
|
|
|
|
|
|
one_thread_scheduler(); |
|
|
#else
|
|
|
#else
|
|
|
if (thread_handling <= SCHEDULER_ONE_THREAD_PER_CONNECTION) |
|
|
if (thread_handling <= SCHEDULER_ONE_THREAD_PER_CONNECTION) |
|
|
one_thread_per_connection_scheduler(&thread_scheduler); |
|
|
|
|
|
else if (thread_handling == SCHEDULER_NO_THREADS) |
|
|
|
|
|
one_thread_scheduler(&thread_scheduler); |
|
|
|
|
|
else |
|
|
|
|
|
pool_of_threads_scheduler(&thread_scheduler); /* purecov: tested */ |
|
|
|
|
|
|
|
|
one_thread_per_connection_scheduler(); |
|
|
|
|
|
else /* thread_handling == SCHEDULER_NO_THREADS) */ |
|
|
|
|
|
one_thread_scheduler(); |
|
|
#endif
|
|
|
#endif
|
|
|
|
|
|
|
|
|
global_system_variables.engine_condition_pushdown= |
|
|
global_system_variables.engine_condition_pushdown= |
|
|
|