summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2015-08-11 18:45:38 +0200
committerSergei Golubchik <serg@mariadb.org>2015-09-04 10:33:56 +0200
commite3982cead235e9becb1abdbf0e73876c8a6e6b28 (patch)
treee02c8ac4c2a978aa12f1f9fdf19ec5303f7e9341 /sql
parent21daa7b9298d31ab1c6ddd1159dba29acea8d868 (diff)
downloadmariadb-git-e3982cead235e9becb1abdbf0e73876c8a6e6b28.tar.gz
MDEV-6066: Merge new defaults from 5.6 and 5.7 (defaults changed, QC can be stopped with no-zero size)
Diffstat (limited to 'sql')
-rw-r--r--sql/mysqld.cc36
-rw-r--r--sql/sql_cache.cc10
-rw-r--r--sql/sql_const.h2
-rw-r--r--sql/sys_vars.cc69
4 files changed, 72 insertions, 45 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 2265c6607b1..6d35f53a1d9 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -4328,6 +4328,27 @@ static int init_common_variables()
}
#endif /* HAVE_SOLARIS_LARGE_PAGES */
+
+ /* 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))
+ {
+ if ((900 - 50) * 5 >= max_connections)
+ SYSVAR_AUTOSIZE(back_log, (50 + max_connections / 5));
+ else
+ SYSVAR_AUTOSIZE(back_log, 900);
+ }
+
/* connections and databases needs lots of files */
{
uint files, wanted_files, max_open_files;
@@ -4873,9 +4894,16 @@ static int init_server_components()
unireg_abort(1);
query_cache_set_min_res_unit(query_cache_min_res_unit);
+ query_cache_result_size_limit(query_cache_limit);
+ /* if we set size of QC non zero in config then probably we want it ON */
+ if (query_cache_size != 0 &&
+ global_system_variables.query_cache_type == 0 &&
+ !IS_SYSVAR_AUTOSIZE(&query_cache_size))
+ {
+ global_system_variables.query_cache_type= 1;
+ }
query_cache_init();
query_cache_resize(query_cache_size);
- query_cache_result_size_limit(query_cache_limit);
my_rnd_init(&sql_rand,(ulong) server_start_time,(ulong) server_start_time/2);
setup_fpu();
init_thr_lock();
@@ -5552,6 +5580,12 @@ int mysqld_main(int argc, char **argv)
int ho_error __attribute__((unused))= handle_early_options();
+ /* fix tdc_size */
+ if (IS_SYSVAR_AUTOSIZE(&tdc_size))
+ {
+ SYSVAR_AUTOSIZE(tdc_size, MY_MIN(400 + tdc_size / 2, 2000));
+ }
+
#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
if (ho_error == 0)
{
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index 2dd8976d51e..03505dec0cf 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -1295,14 +1295,6 @@ ulong Query_cache::resize(ulong query_cache_size_arg)
query_cache_size_arg));
DBUG_ASSERT(initialized);
- if (global_system_variables.query_cache_type == 0)
- {
- DBUG_ASSERT(query_cache_size_arg == 0);
- if (query_cache_size_arg != 0)
- my_error(ER_QUERY_CACHE_IS_DISABLED, MYF(0));
- DBUG_RETURN(0);
- }
-
lock_and_suspend();
/*
@@ -1340,7 +1332,7 @@ ulong Query_cache::resize(ulong query_cache_size_arg)
m_cache_status is internal query cache switch so switching it on/off
will not be reflected on global_system_variables.query_cache_type
*/
- if (new_query_cache_size)
+ if (new_query_cache_size && global_system_variables.query_cache_type != 0)
{
DBUG_EXECUTE("check_querycache",check_integrity(1););
m_cache_status= OK; // size > 0 => enable cache
diff --git a/sql/sql_const.h b/sql/sql_const.h
index 18a74d8579e..c8bb442376e 100644
--- a/sql/sql_const.h
+++ b/sql/sql_const.h
@@ -111,7 +111,7 @@
#define MAX_FIELDS_BEFORE_HASH 32
#define USER_VARS_HASH_SIZE 16
#define TABLE_OPEN_CACHE_MIN 400
-#define TABLE_OPEN_CACHE_DEFAULT 400
+#define TABLE_OPEN_CACHE_DEFAULT 2000
#define TABLE_DEF_CACHE_DEFAULT 400
/**
We must have room for at least 400 table definitions in the table
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 387fe1b7ef7..70dfc10e29d 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -370,10 +370,10 @@ static Sys_var_mybool Sys_automatic_sp_privileges(
static Sys_var_ulong Sys_back_log(
"back_log", "The number of outstanding connection requests "
- "MySQL can have. This comes into play when the main MySQL thread "
+ "MariaDB can have. This comes into play when the main MySQL thread "
"gets very many connection requests in a very short time",
- READ_ONLY GLOBAL_VAR(back_log), CMD_LINE(REQUIRED_ARG),
- VALID_RANGE(1, 65535), DEFAULT(150), BLOCK_SIZE(1));
+ AUTO_SET READ_ONLY GLOBAL_VAR(back_log), CMD_LINE(REQUIRED_ARG),
+ VALID_RANGE(0, 65535), DEFAULT(150), BLOCK_SIZE(1));
static Sys_var_charptr Sys_basedir(
"basedir", "Path to installation directory. All paths are "
@@ -1035,7 +1035,7 @@ static Sys_var_ulonglong Sys_join_buffer_size(
"join_buffer_size",
"The size of the buffer that is used for joins",
SESSION_VAR(join_buff_size), CMD_LINE(REQUIRED_ARG),
- VALID_RANGE(128, SIZE_T_MAX), DEFAULT(128*1024), BLOCK_SIZE(128));
+ VALID_RANGE(128, SIZE_T_MAX), DEFAULT(256*1024), BLOCK_SIZE(128));
static Sys_var_keycache Sys_key_buffer_size(
"key_buffer_size", "The size of the buffer used for "
@@ -1286,7 +1286,7 @@ static Sys_var_ulong Sys_max_allowed_packet(
"max_allowed_packet",
"Max packet length to send to or receive from the server",
SESSION_VAR(max_allowed_packet), CMD_LINE(REQUIRED_ARG),
- VALID_RANGE(1024, 1024*1024*1024), DEFAULT(1024*1024),
+ VALID_RANGE(1024, 1024*1024*1024), DEFAULT(4*1024*1024),
BLOCK_SIZE(1024), NO_MUTEX_GUARD, NOT_IN_BINLOG,
ON_CHECK(check_max_allowed_packet));
@@ -2691,17 +2691,6 @@ static Sys_var_enum Sys_thread_handling(
);
#ifdef HAVE_QUERY_CACHE
-static bool check_query_cache_size(sys_var *self, THD *thd, set_var *var)
-{
- if (global_system_variables.query_cache_type == 0 &&
- var->value && var->value->val_int() != 0)
- {
- my_error(ER_QUERY_CACHE_DISABLED, MYF(0));
- return true;
- }
-
- return false;
-}
static bool fix_query_cache_size(sys_var *self, THD *thd, enum_var_type type)
{
ulong new_cache_size= query_cache.resize(query_cache_size);
@@ -2715,8 +2704,10 @@ static bool fix_query_cache_size(sys_var *self, THD *thd, enum_var_type type)
query_cache_size, new_cache_size);
query_cache_size= new_cache_size;
+
return false;
}
+
static bool fix_query_cache_limit(sys_var *self, THD *thd, enum_var_type type)
{
query_cache.result_size_limit(query_cache_limit);
@@ -2726,8 +2717,8 @@ static Sys_var_ulonglong Sys_query_cache_size(
"query_cache_size",
"The memory allocated to store results from old queries",
GLOBAL_VAR(query_cache_size), CMD_LINE(REQUIRED_ARG),
- VALID_RANGE(0, ULONG_MAX), DEFAULT(0), BLOCK_SIZE(1024),
- NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(check_query_cache_size),
+ VALID_RANGE(0, ULONG_MAX), DEFAULT(1024*1024), BLOCK_SIZE(1024),
+ NO_MUTEX_GUARD, NOT_IN_BINLOG, NULL,
ON_UPDATE(fix_query_cache_size));
static Sys_var_ulong Sys_query_cache_limit(
@@ -2753,6 +2744,7 @@ static Sys_var_ulong Sys_query_cache_min_res_unit(
ON_UPDATE(fix_qcache_min_res_unit));
static const char *query_cache_type_names[]= { "OFF", "ON", "DEMAND", 0 };
+
static bool check_query_cache_type(sys_var *self, THD *thd, set_var *var)
{
if (query_cache.is_disable_in_progress())
@@ -2760,16 +2752,22 @@ static bool check_query_cache_type(sys_var *self, THD *thd, set_var *var)
my_error(ER_QUERY_CACHE_IS_DISABLED, MYF(0));
return true;
}
- if (var->type != OPT_GLOBAL &&
- global_system_variables.query_cache_type == 0 &&
- var->value->val_int() != 0)
+
+ if (var->type != OPT_GLOBAL && global_system_variables.query_cache_type == 0)
{
- my_error(ER_QUERY_CACHE_IS_GLOBALY_DISABLED, MYF(0));
- return true;
+ if (var->value)
+ {
+ if (var->save_result.ulonglong_value != 0)
+ {
+ my_error(ER_QUERY_CACHE_IS_GLOBALY_DISABLED, MYF(0));
+ return true;
+ }
+ }
}
-
return false;
}
+
+
static bool fix_query_cache_type(sys_var *self, THD *thd, enum_var_type type)
{
if (type != OPT_GLOBAL)
@@ -2793,7 +2791,7 @@ static Sys_var_enum Sys_query_cache_type(
"except SELECT SQL_NO_CACHE ... queries. DEMAND = Cache only "
"SELECT SQL_CACHE ... queries",
NO_SET_STMT SESSION_VAR(query_cache_type), CMD_LINE(REQUIRED_ARG),
- query_cache_type_names, DEFAULT(1), NO_MUTEX_GUARD, NOT_IN_BINLOG,
+ query_cache_type_names, DEFAULT(0), NO_MUTEX_GUARD, NOT_IN_BINLOG,
ON_CHECK(check_query_cache_type),
ON_UPDATE(fix_query_cache_type));
@@ -2809,7 +2807,7 @@ static Sys_var_mybool Sys_secure_auth(
"Disallow authentication for accounts that have old (pre-4.1) "
"passwords",
GLOBAL_VAR(opt_secure_auth), CMD_LINE(OPT_ARG),
- DEFAULT(FALSE));
+ DEFAULT(TRUE));
static Sys_var_charptr Sys_secure_file_priv(
"secure_file_priv",
@@ -3062,7 +3060,10 @@ static Sys_var_set Sys_sql_mode(
"sql_mode",
"Sets the sql mode",
SESSION_VAR(sql_mode), CMD_LINE(REQUIRED_ARG),
- sql_mode_names, DEFAULT(0), NO_MUTEX_GUARD, NOT_IN_BINLOG,
+ sql_mode_names,
+ DEFAULT(MODE_NO_ENGINE_SUBSTITUTION |
+ MODE_NO_AUTO_CREATE_USER),
+ NO_MUTEX_GUARD, NOT_IN_BINLOG,
ON_CHECK(check_sql_mode), ON_UPDATE(fix_sql_mode));
static const char *old_mode_names[]=
@@ -4507,16 +4508,16 @@ static Sys_var_ulonglong Sys_relay_log_space_limit(
static Sys_var_uint Sys_sync_relaylog_period(
"sync_relay_log", "Synchronously flush relay log to disk after "
- "every #th event. Use 0 (default) to disable synchronous flushing",
+ "every #th event. Use 0 to disable synchronous flushing",
GLOBAL_VAR(sync_relaylog_period), CMD_LINE(REQUIRED_ARG),
- VALID_RANGE(0, UINT_MAX), DEFAULT(0), BLOCK_SIZE(1));
+ VALID_RANGE(0, UINT_MAX), DEFAULT(10000), BLOCK_SIZE(1));
static Sys_var_uint Sys_sync_relayloginfo_period(
"sync_relay_log_info", "Synchronously flush relay log info "
- "to disk after every #th transaction. Use 0 (default) to disable "
+ "to disk after every #th transaction. Use 0 to disable "
"synchronous flushing",
GLOBAL_VAR(sync_relayloginfo_period), CMD_LINE(REQUIRED_ARG),
- VALID_RANGE(0, UINT_MAX), DEFAULT(0), BLOCK_SIZE(1));
+ VALID_RANGE(0, UINT_MAX), DEFAULT(10000), BLOCK_SIZE(1));
#endif
static Sys_var_uint Sys_sync_binlog_period(
@@ -4527,9 +4528,9 @@ static Sys_var_uint Sys_sync_binlog_period(
static Sys_var_uint Sys_sync_masterinfo_period(
"sync_master_info", "Synchronously flush master info to disk "
- "after every #th event. Use 0 (default) to disable synchronous flushing",
+ "after every #th event. Use 0 to disable synchronous flushing",
GLOBAL_VAR(sync_masterinfo_period), CMD_LINE(REQUIRED_ARG),
- VALID_RANGE(0, UINT_MAX), DEFAULT(0), BLOCK_SIZE(1));
+ VALID_RANGE(0, UINT_MAX), DEFAULT(10000), BLOCK_SIZE(1));
#ifdef HAVE_REPLICATION
static Sys_var_ulong Sys_slave_trans_retries(
@@ -4929,7 +4930,7 @@ static bool fix_host_cache_size(sys_var *, THD *, enum_var_type)
static Sys_var_ulong Sys_host_cache_size(
"host_cache_size",
"How many host names should be cached to avoid resolving.",
- GLOBAL_VAR(host_cache_size),
+ AUTO_SET GLOBAL_VAR(host_cache_size),
CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 65536),
DEFAULT(HOST_CACHE_SIZE),
BLOCK_SIZE(1),