267
268
uint32_t tc_heuristic_recover= 0;
268
269
uint64_t session_startup_options;
269
270
uint32_t back_log;
270
uint32_t connect_timeout;
271
271
uint32_t server_id;
272
272
uint64_t table_cache_size;
273
273
uint64_t table_def_size;
274
274
uint64_t aborted_threads;
275
275
uint64_t aborted_connects;
276
276
uint64_t max_connect_errors;
277
uint32_t thread_id=1L;
277
uint32_t global_thread_id=1L;
278
278
pid_t current_pid;
280
280
const double log_10[] = {
876
872
(uint32_t) dflt_key_cache->key_cache_mem_size);
877
873
fprintf(stderr, "read_buffer_size=%ld\n", (long) global_system_variables.read_buff_size);
878
874
fprintf(stderr, "max_used_connections=%u\n", max_used_connections);
879
fprintf(stderr, "max_threads=%u\n", thread_scheduler.get_max_threads());
880
fprintf(stderr, "thread_count=%u\n", thread_scheduler.count());
881
875
fprintf(stderr, "connection_count=%u\n", uint32_t(connection_count));
882
876
fprintf(stderr, _("It is possible that drizzled could use up to \n"
883
877
"key_buffer_size + (read_buffer_size + "
884
"sort_buffer_size)*max_threads = %"PRIu64" K\n"
878
"sort_buffer_size)*thread_count\n"
885
879
"bytes of memory\n"
886
880
"Hope that's ok; if not, decrease some variables in the "
888
(uint64_t)(((uint32_t) dflt_key_cache->key_cache_mem_size +
889
(global_system_variables.read_buff_size +
890
global_system_variables.sortbuff_size) *
891
thread_scheduler.get_max_threads()) / 1024));
893
883
#ifdef HAVE_STACKTRACE
894
884
Session *session= current_session;
1619
Create new thread to handle incoming connection.
1621
This function will create new thread to handle the incoming
1622
connection. If there are idle cached threads one will be used.
1623
'session' will be pushed into 'threads'.
1625
In single-threaded mode (\#define ONE_THREAD) connection will be
1626
handled inside this function.
1628
@param[in,out] session Thread handle of future thread.
1631
static void create_new_thread(Session *session)
1633
Scheduler &thread_scheduler= get_thread_scheduler();
1637
if (connection_count > max_used_connections)
1638
max_used_connections= connection_count;
1641
The initialization of thread_id is done in create_embedded_session() for
1642
the embedded library.
1643
TODO: refactor this to avoid code duplication there
1645
session->thread_id= session->variables.pseudo_thread_id= thread_id++;
1648
If we error on creation we drop the connection and delete the session.
1650
pthread_mutex_lock(&LOCK_thread_count);
1651
session_list.push_back(session);
1652
pthread_mutex_unlock(&LOCK_thread_count);
1653
if (thread_scheduler.add_connection(session))
1655
char error_message_buff[DRIZZLE_ERRMSG_SIZE];
1657
session->killed= Session::KILL_CONNECTION; // Safety
1659
statistic_increment(aborted_connects, &LOCK_status);
1661
/* Can't use my_error() since store_globals has not been called. */
1662
snprintf(error_message_buff, sizeof(error_message_buff), ER(ER_CANT_CREATE_THREAD), 1); /* TODO replace will better error message */
1663
session->protocol->sendError(ER_CANT_CREATE_THREAD, error_message_buff);
1664
unlink_session(session);
1669
1610
/****************************************************************************
1670
1611
Handle start options
1671
1612
******************************************************************************/
1704
1644
OPT_MYISAM_MAX_SORT_FILE_SIZE, OPT_MYISAM_SORT_BUFFER_SIZE,
1705
1645
OPT_MYISAM_USE_MMAP, OPT_MYISAM_REPAIR_THREADS,
1706
1646
OPT_MYISAM_STATS_METHOD,
1707
OPT_NET_BUFFER_LENGTH, OPT_NET_RETRY_COUNT,
1708
OPT_NET_READ_TIMEOUT, OPT_NET_WRITE_TIMEOUT,
1647
OPT_NET_BUFFER_LENGTH,
1709
1648
OPT_PRELOAD_BUFFER_SIZE,
1710
1649
OPT_RECORD_BUFFER,
1711
1650
OPT_RECORD_RND_BUFFER, OPT_DIV_PRECINCREMENT,
1902
1839
(char**) &global_system_variables.bulk_insert_buff_size,
1903
1840
(char**) &max_system_variables.bulk_insert_buff_size,
1904
1841
0, GET_ULL, REQUIRED_ARG, 8192*1024, 0, ULONG_MAX, 0, 1, 0},
1905
{ "connect_timeout", OPT_CONNECT_TIMEOUT,
1906
N_("The number of seconds the drizzled server is waiting for a connect "
1907
"packet before responding with 'Bad handshake'."),
1908
(char**) &connect_timeout, (char**) &connect_timeout,
1909
0, GET_UINT32, REQUIRED_ARG, CONNECT_TIMEOUT, 2, LONG_TIMEOUT, 0, 1, 0 },
1910
1842
{ "div_precision_increment", OPT_DIV_PRECINCREMENT,
1911
1843
N_("Precision of the result of '/' operator will be increased on that "
2020
1952
(char**) &global_system_variables.net_buffer_length,
2021
1953
(char**) &max_system_variables.net_buffer_length, 0, GET_UINT32,
2022
1954
REQUIRED_ARG, 16384, 1024, 1024*1024L, 0, 1024, 0},
2023
{"net_read_timeout", OPT_NET_READ_TIMEOUT,
2024
N_("Number of seconds to wait for more data from a connection before "
2025
"aborting the read."),
2026
(char**) &global_system_variables.net_read_timeout,
2027
(char**) &max_system_variables.net_read_timeout, 0, GET_UINT32,
2028
REQUIRED_ARG, NET_READ_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
2029
{"net_retry_count", OPT_NET_RETRY_COUNT,
2030
N_("If a read on a communication port is interrupted, retry this many "
2031
"times before giving up."),
2032
(char**) &global_system_variables.net_retry_count,
2033
(char**) &max_system_variables.net_retry_count,0,
2034
GET_UINT32, REQUIRED_ARG, MYSQLD_NET_RETRY_COUNT, 1, ULONG_MAX, 0, 1, 0},
2035
{"net_write_timeout", OPT_NET_WRITE_TIMEOUT,
2036
N_("Number of seconds to wait for a block to be written to a connection "
2037
"before aborting the write."),
2038
(char**) &global_system_variables.net_write_timeout,
2039
(char**) &max_system_variables.net_write_timeout, 0, GET_UINT32,
2040
REQUIRED_ARG, NET_WRITE_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0},
2041
1955
{"optimizer_prune_level", OPT_OPTIMIZER_PRUNE_LEVEL,
2042
1956
N_("Controls the heuristic(s) applied during query optimization to prune "
2043
1957
"less-promising partial plans from the optimizer search space. Meaning: "
2151
2065
(char**) &global_system_variables.trans_prealloc_size,
2152
2066
(char**) &max_system_variables.trans_prealloc_size, 0, GET_UINT,
2153
2067
REQUIRED_ARG, TRANS_ALLOC_PREALLOC_SIZE, 1024, ULONG_MAX, 0, 1024, 0},
2154
{"wait_timeout", OPT_WAIT_TIMEOUT,
2155
N_("The number of seconds the server waits for activity on a connection "
2156
"before closing it."),
2157
(char**) &global_system_variables.net_wait_timeout,
2158
(char**) &max_system_variables.net_wait_timeout, 0, GET_UINT,
2159
REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, LONG_TIMEOUT,
2161
2068
{0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
2214
2121
{"Bytes_received", (char*) offsetof(STATUS_VAR, bytes_received), SHOW_LONGLONG_STATUS},
2215
2122
{"Bytes_sent", (char*) offsetof(STATUS_VAR, bytes_sent), SHOW_LONGLONG_STATUS},
2216
2123
{"Com", (char*) com_status_vars, SHOW_ARRAY},
2217
{"Connections", (char*) &thread_id, SHOW_INT_NOFLUSH},
2124
{"Connections", (char*) &global_thread_id, SHOW_INT_NOFLUSH},
2218
2125
{"Created_tmp_disk_tables", (char*) offsetof(STATUS_VAR, created_tmp_disk_tables), SHOW_LONG_STATUS},
2219
2126
{"Created_tmp_files", (char*) &my_tmp_file_created,SHOW_INT},
2220
2127
{"Created_tmp_tables", (char*) offsetof(STATUS_VAR, created_tmp_tables), SHOW_LONG_STATUS},