diff options
author | Monty <monty@mariadb.org> | 2017-09-26 00:12:36 +0300 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2017-09-26 00:13:04 +0300 |
commit | a02b81daeaa63c327bea9e6c24fe45b53dc0008e (patch) | |
tree | a4d22136da545fe1b8d363b77b773df08b173dc7 /sql | |
parent | 742263df4f43ac8ffb611de607fb8337296ae949 (diff) | |
download | mariadb-git-a02b81daeaa63c327bea9e6c24fe45b53dc0008e.tar.gz |
Moved autosetting of host_cache_size and back_log to proper placebb-10-3-marko
- Clean up formulas and comments for host_cache_size and back_log
- Added test of autoset (for host_cache_size)
- Marked open_files_limit as auto_set
Diffstat (limited to 'sql')
-rw-r--r-- | sql/mysqld.cc | 47 | ||||
-rw-r--r-- | sql/sys_vars.cc | 8 |
2 files changed, 35 insertions, 20 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc index f464ec807f6..e552d0b05a6 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4400,21 +4400,6 @@ static int init_common_variables() SYSVAR_AUTOSIZE(threadpool_size, my_getncpus()); #endif - /* Fix host_cache_size. */ - if (IS_SYSVAR_AUTOSIZE(&host_cache_size)) - { - if (max_connections <= 628 - 128) - SYSVAR_AUTOSIZE(host_cache_size, 128 + max_connections); - else if (max_connections <= ((ulong)(2000 - 628)) * 20 + 500) - SYSVAR_AUTOSIZE(host_cache_size, 628 + ((max_connections - 500) / 20)); - else - SYSVAR_AUTOSIZE(host_cache_size, 2000); - } - - /* Fix back_log (back_log == 0 added for MySQL compatibility) */ - if (back_log == 0 || IS_SYSVAR_AUTOSIZE(&back_log)) - SYSVAR_AUTOSIZE(back_log, MY_MIN(900, (50 + max_connections / 5))); - /* connections and databases needs lots of files */ { uint files, wanted_files, max_open_files; @@ -4439,7 +4424,7 @@ static int init_common_variables() if (files < wanted_files) { - if (!open_files_limit) + if (!open_files_limit || IS_SYSVAR_AUTOSIZE(&open_files_limit)) { /* If we have requested too much file handles than we bring @@ -4468,6 +4453,36 @@ static int init_common_variables() } SYSVAR_AUTOSIZE(open_files_limit, files); } + + /* + Max_connections is now set. + Now we can fix other variables depending on this variable. + */ + + /* Fix host_cache_size */ + if (IS_SYSVAR_AUTOSIZE(&host_cache_size)) + { + /* + The default value is 128. + The autoset value is 128, plus 1 for a value of max_connections + up to 500, plus 1 for every increment of 20 over 500 in the + max_connections value, capped at 2000. + */ + uint size= (HOST_CACHE_SIZE + MY_MIN(max_connections, 500) + + MY_MAX(((long) max_connections)-500,0)/20); + SYSVAR_AUTOSIZE(host_cache_size, size); + } + + /* Fix back_log (back_log == 0 added for MySQL compatibility) */ + if (back_log == 0 || IS_SYSVAR_AUTOSIZE(&back_log)) + { + /* + The default value is 150. + The autoset value is 50 + max_connections / 5 capped at 900 + */ + SYSVAR_AUTOSIZE(back_log, MY_MIN(900, (50 + max_connections / 5))); + } + unireg_init(opt_specialflag); /* Set up extern variabels */ if (!(my_default_lc_messages= my_locale_by_name(lc_messages))) diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 7405ca7e884..6f3ccfc9823 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -2311,10 +2311,10 @@ export sys_var *Sys_old_passwords_ptr= &Sys_old_passwords; // for sql_acl.cc static Sys_var_ulong Sys_open_files_limit( "open_files_limit", "If this is not 0, then mysqld will use this value to reserve file " - "descriptors to use with setrlimit(). If this value is 0 then mysqld " - "will reserve max_connections*5 or max_connections + table_cache*2 " - "(whichever is larger) number of file descriptors", - READ_ONLY GLOBAL_VAR(open_files_limit), CMD_LINE(REQUIRED_ARG), + "descriptors to use with setrlimit(). If this value is 0 or autoset " + "then mysqld will reserve max_connections*5 or max_connections + " + "table_cache*2 (whichever is larger) number of file descriptors", + AUTO_SET READ_ONLY GLOBAL_VAR(open_files_limit), CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, OS_FILE_LIMIT), DEFAULT(0), BLOCK_SIZE(1)); /// @todo change to enum |