summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorDaniele Sciascia <daniele.sciascia@galeracluster.com>2016-05-06 16:07:53 +0200
committerNirbhay Choubey <nirbhay@mariadb.com>2016-07-25 11:44:57 -0400
commit74f80b349924c7f0c091a0973dea0ec61191c2c9 (patch)
treec6d0265edd1470a850c70eda77f773ea315ca85b /sql
parent5197fcf6b4611a26b3847d1101f1a4fb6d17570a (diff)
downloadmariadb-git-74f80b349924c7f0c091a0973dea0ec61191c2c9.tar.gz
MW-267 Enforce wsrep_max_ws_size limit in wsrep provider
This changes variable wsrep_max_ws_size so that its value is linked to the value of provider option repl.max_ws_size. That is, changing the value of variable wsrep_max_ws_size will change the value of provider option repl.max_ws_size, and viceversa. The writeset size limit is always enforced in the provider, regardless of which option is used.
Diffstat (limited to 'sql')
-rw-r--r--sql/sys_vars.cc5
-rw-r--r--sql/wsrep_applier.cc10
-rw-r--r--sql/wsrep_binlog.h2
-rw-r--r--sql/wsrep_var.cc48
-rw-r--r--sql/wsrep_var.h2
5 files changed, 53 insertions, 14 deletions
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index 0bfa0bf5eb0..0ac8d40fbae 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -4688,8 +4688,9 @@ static Sys_var_charptr Sys_wsrep_start_position (
static Sys_var_ulong Sys_wsrep_max_ws_size (
"wsrep_max_ws_size", "Max write set size (bytes)",
GLOBAL_VAR(wsrep_max_ws_size), CMD_LINE(REQUIRED_ARG),
- /* Upper limit is 65K short of 4G to avoid overlows on 32-bit systems */
- VALID_RANGE(1024, WSREP_MAX_WS_SIZE), DEFAULT(1073741824UL), BLOCK_SIZE(1));
+ VALID_RANGE(1024, WSREP_MAX_WS_SIZE), DEFAULT(WSREP_MAX_WS_SIZE),
+ BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0),
+ ON_UPDATE(wsrep_max_ws_size_update));
static Sys_var_ulong Sys_wsrep_max_ws_rows (
"wsrep_max_ws_rows", "Max number of rows in write set",
diff --git a/sql/wsrep_applier.cc b/sql/wsrep_applier.cc
index 90c84f1c2cc..73a43185162 100644
--- a/sql/wsrep_applier.cc
+++ b/sql/wsrep_applier.cc
@@ -39,15 +39,9 @@ static Log_event* wsrep_read_log_event(
const char *error= 0;
Log_event *res= 0;
- if (data_len > wsrep_max_ws_size)
- {
- error = "Event too big";
- goto err;
- }
-
- res= Log_event::read_log_event(buf, data_len, &error, description_event, true);
+ res= Log_event::read_log_event(buf, data_len, &error, description_event,
+ true);
-err:
if (!res)
{
DBUG_ASSERT(error != 0);
diff --git a/sql/wsrep_binlog.h b/sql/wsrep_binlog.h
index a7b680f616b..c29d51caf2c 100644
--- a/sql/wsrep_binlog.h
+++ b/sql/wsrep_binlog.h
@@ -19,7 +19,7 @@
#include "sql_class.h" // THD, IO_CACHE
#define HEAP_PAGE_SIZE 65536 /* 64K */
-#define WSREP_MAX_WS_SIZE (0xFFFFFFFFUL - HEAP_PAGE_SIZE)
+#define WSREP_MAX_WS_SIZE 2147483647 /* 2GB */
/*
Write the contents of a cache to a memory buffer.
diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc
index 7ac68df66bd..44d17e3e78a 100644
--- a/sql/wsrep_var.cc
+++ b/sql/wsrep_var.cc
@@ -179,6 +179,32 @@ void wsrep_start_position_init (const char* val)
wsrep_set_local_position (val, false);
}
+static int get_provider_option_value(const char* opts,
+ const char* opt_name,
+ ulong* opt_value)
+{
+ int ret= 1;
+ ulong opt_value_tmp;
+ char *opt_value_str, *s, *opts_copy= my_strdup(opts, MYF(MY_WME));
+
+ if ((opt_value_str= strstr(opts_copy, opt_name)) == NULL)
+ goto end;
+ opt_value_str= strtok_r(opt_value_str, "=", &s);
+ if (opt_value_str == NULL) goto end;
+ opt_value_str= strtok_r(NULL, ";", &s);
+ if (opt_value_str == NULL) goto end;
+
+ opt_value_tmp= strtoul(opt_value_str, NULL, 10);
+ if (errno == ERANGE) goto end;
+
+ *opt_value= opt_value_tmp;
+ ret= 0;
+
+end:
+ my_free(opts_copy);
+ return ret;
+}
+
static bool refresh_provider_options()
{
WSREP_DEBUG("refresh_provider_options: %s",
@@ -186,9 +212,10 @@ static bool refresh_provider_options()
char* opts= wsrep->options_get(wsrep);
if (opts)
{
- if (wsrep_provider_options) my_free((void *)wsrep_provider_options);
- wsrep_provider_options = (char*)my_memdup(opts, strlen(opts) + 1,
- MYF(MY_WME));
+ wsrep_provider_options_init(opts);
+ get_provider_option_value(wsrep_provider_options,
+ (char*)"repl.max_ws_size",
+ &wsrep_max_ws_size);
}
else
{
@@ -531,6 +558,21 @@ bool wsrep_desync_update (sys_var *self, THD* thd, enum_var_type type)
return false;
}
+bool wsrep_max_ws_size_update (sys_var *self, THD *thd, enum_var_type)
+{
+ char max_ws_size_opt[128];
+ my_snprintf(max_ws_size_opt, sizeof(max_ws_size_opt),
+ "repl.max_ws_size=%d", wsrep_max_ws_size);
+ wsrep_status_t ret= wsrep->options_set(wsrep, max_ws_size_opt);
+ if (ret != WSREP_OK)
+ {
+ WSREP_ERROR("Set options returned %d", ret);
+ refresh_provider_options();
+ return true;
+ }
+ return refresh_provider_options();
+}
+
/*
* Status variables stuff below
*/
diff --git a/sql/wsrep_var.h b/sql/wsrep_var.h
index 524dabfd9c0..f72df9d098a 100644
--- a/sql/wsrep_var.h
+++ b/sql/wsrep_var.h
@@ -83,4 +83,6 @@ extern bool wsrep_slave_threads_update UPDATE_ARGS;
extern bool wsrep_desync_check CHECK_ARGS;
extern bool wsrep_desync_update UPDATE_ARGS;
+extern bool wsrep_max_ws_size_update UPDATE_ARGS;
+
#endif /* WSREP_VAR_H */