summaryrefslogtreecommitdiff
path: root/sql/wsrep_var.cc
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/wsrep_var.cc
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/wsrep_var.cc')
-rw-r--r--sql/wsrep_var.cc48
1 files changed, 45 insertions, 3 deletions
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
*/