311
311
ulong what_to_log;
312
312
uint64_t slow_launch_time;
313
313
uint64_t slave_open_temp_tables;
314
uint64_t open_files_limit;
315
314
uint32_t refresh_version; /* Increments on each reload */
316
315
uint64_t aborted_threads;
317
316
uint64_t aborted_connects;
318
uint64_t max_connections;
319
317
uint64_t max_connect_errors;
320
318
ulong thread_id=1L;
321
319
pid_t current_pid;
1257
1255
(uint64_t)(((uint32_t) dflt_key_cache->key_cache_mem_size +
1258
1256
(global_system_variables.read_buff_size +
1259
1257
global_system_variables.sortbuff_size) *
1260
thread_scheduler.max_threads +
1261
max_connections * sizeof(Session)) / 1024));
1258
thread_scheduler.max_threads) / 1024));
1263
1260
#ifdef HAVE_STACKTRACE
1264
1261
Session *session= current_session;
1836
1833
/* connections and databases needs lots of files */
1838
uint64_t files, wanted_files, max_open_files;
1840
/* MyISAM requires two file handles per table. */
1841
wanted_files= 10+max_connections+table_cache_size*2;
1843
We are trying to allocate no less than max_connections*5 file
1844
handles (i.e. we are trying to set the limit so that they will
1845
be available). In addition, we allocate no less than how much
1846
was already allocated. However below we report a warning and
1847
recompute values only if we got less file handles than were
1848
explicitly requested. No warning and re-computation occur if we
1849
can't get max_connections*5 but still got no less than was
1850
requested (value of wanted_files).
1852
max_open_files= cmax(cmax((uint32_t)wanted_files, max_connections*5),
1854
files= my_set_max_open_files(max_open_files);
1856
if (files < wanted_files)
1858
if (!open_files_limit)
1861
If we have requested too much file handles than we bring
1862
max_connections in supported bounds.
1864
max_connections= (uint32_t) cmin((uint32_t)files-10-TABLE_OPEN_CACHE_MIN*2,
1867
Decrease table_cache_size according to max_connections, but
1868
not below TABLE_OPEN_CACHE_MIN. Outer cmin() ensures that we
1869
never increase table_cache_size automatically (that could
1870
happen if max_connections is decreased above).
1872
table_cache_size= (uint32_t) cmin(cmax((files-10-max_connections)/2,
1873
(uint32_t)TABLE_OPEN_CACHE_MIN),
1875
if (global_system_variables.log_warnings)
1876
errmsg_printf(ERRMSG_LVL_WARN, _("Changed limits: max_open_files: %u "
1877
"max_connections: %"PRIu64" table_cache: %"PRIu64""),
1878
files, max_connections, table_cache_size);
1880
else if (global_system_variables.log_warnings)
1881
errmsg_printf(ERRMSG_LVL_WARN, _("Could not increase number of max_open_files "
1882
"to more than %u (request: %u)"),
1883
files, wanted_files);
1885
open_files_limit= files;
1834
(void) my_set_max_open_files(0xFFFFFFFF);
1887
1836
unireg_init(); /* Set up extern variabels */
1888
1837
if (init_errmessage()) /* Read error messages from file */
2328
2277
static void create_new_thread(Session *session)
2332
Don't allow too many connections. We roughly check here that we allow
2333
only (max_connections + 1) connections.
2336
2280
pthread_mutex_lock(&LOCK_connection_count);
2338
if (connection_count >= max_connections + 1 || abort_loop)
2340
pthread_mutex_unlock(&LOCK_connection_count);
2342
session->close_connection(ER_CON_COUNT_ERROR, 1);
2347
2282
++connection_count;
2349
2284
if (connection_count > max_used_connections)
2547
2482
OPT_KEY_CACHE_DIVISION_LIMIT, OPT_KEY_CACHE_AGE_THRESHOLD,
2548
2483
OPT_LONG_QUERY_TIME,
2549
2484
OPT_LOWER_CASE_TABLE_NAMES, OPT_MAX_ALLOWED_PACKET,
2550
OPT_MAX_CONNECTIONS, OPT_MAX_CONNECT_ERRORS,
2485
OPT_MAX_CONNECT_ERRORS,
2551
2486
OPT_MAX_HEP_TABLE_SIZE,
2552
2487
OPT_MAX_JOIN_SIZE,
2553
2488
OPT_MAX_RELAY_LOG_SIZE, OPT_MAX_SORT_LENGTH,
2561
2496
OPT_MYISAM_STATS_METHOD,
2562
2497
OPT_NET_BUFFER_LENGTH, OPT_NET_RETRY_COUNT,
2563
2498
OPT_NET_READ_TIMEOUT, OPT_NET_WRITE_TIMEOUT,
2564
OPT_OPEN_FILES_LIMIT,
2565
2499
OPT_PRELOAD_BUFFER_SIZE,
2566
2500
OPT_RECORD_BUFFER,
2567
2501
OPT_RECORD_RND_BUFFER, OPT_DIV_PRECINCREMENT, OPT_RELAY_LOG_SPACE_LIMIT,
2944
2878
"host this host will be blocked from further connections."),
2945
2879
(char**) &max_connect_errors, (char**) &max_connect_errors, 0, GET_ULONG,
2946
2880
REQUIRED_ARG, MAX_CONNECT_ERRORS, 1, ULONG_MAX, 0, 1, 0},
2947
// Default max_connections of 151 is larger than Apache's default max
2948
// children, to avoid "too many connections" error in a common setup
2949
{"max_connections", OPT_MAX_CONNECTIONS,
2950
N_("The number of simultaneous clients allowed."),
2951
(char**) &max_connections,
2952
(char**) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 2048, 1, 100000, 0, 1, 0},
2953
2881
{"max_error_count", OPT_MAX_ERROR_COUNT,
2954
2882
N_("Max number of errors/warnings to store for a statement."),
2955
2883
(char**) &global_system_variables.max_error_count,
3034
2962
(char**) &global_system_variables.old_mode,
3035
2963
(char**) &max_system_variables.old_mode, 0, GET_BOOL, NO_ARG,
3036
2964
0, 0, 0, 0, 0, 0},
3037
{"open_files_limit", OPT_OPEN_FILES_LIMIT,
3038
N_("If this is not 0, then drizzled will use this value to reserve file "
3039
"descriptors to use with setrlimit(). If this value is 0 then drizzled "
3040
"will reserve max_connections*5 or max_connections + table_cache*2 "
3041
"(whichever is larger) number of files."),
3042
(char**) &open_files_limit, (char**) &open_files_limit, 0, GET_ULL,
3043
REQUIRED_ARG, 0, 0, OS_FILE_LIMIT, 0, 1, 0},
3044
2965
{"optimizer_prune_level", OPT_OPTIMIZER_PRUNE_LEVEL,
3045
2966
N_("Controls the heuristic(s) applied during query optimization to prune "
3046
2967
"less-promising partial plans from the optimizer search space. Meaning: "