Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MDEV-31636 Memory leak in Sys_var_gtid_binlog_state::do_check() #3523

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions mysql-test/main/mdev-31636.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
RESET MASTER;
SET
@@global.gtid_binlog_state='1-1-101,2-1-2002',
@@global.slave_parallel_mode=x;
ERROR 42000: Variable 'slave_parallel_mode' can't be set to the value of 'x'
SELECT @@global.gtid_binlog_state;
@@global.gtid_binlog_state

7 changes: 7 additions & 0 deletions mysql-test/main/mdev-31636.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
--source include/have_log_bin.inc
RESET MASTER;
--error ER_WRONG_VALUE_FOR_VAR
SET
@@global.gtid_binlog_state='1-1-101,2-1-2002',
@@global.slave_parallel_mode=x;
SELECT @@global.gtid_binlog_state;
58 changes: 28 additions & 30 deletions sql/sys_vars.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2016,15 +2016,6 @@ struct gtid_binlog_state_data { rpl_gtid *list; uint32 list_len; };
bool
Sys_var_gtid_binlog_state::do_check(THD *thd, set_var *var)
{
String str, *res;
struct gtid_binlog_state_data *data;
rpl_gtid *list;
uint32 list_len;

DBUG_ASSERT(var->type == OPT_GLOBAL);

if (!(res= var->value->val_str(&str)))
return true;
if (thd->in_active_multi_stmt_transaction())
{
my_error(ER_CANT_DO_THIS_DURING_AN_TRANSACTION, MYF(0));
Expand All @@ -2040,6 +2031,31 @@ Sys_var_gtid_binlog_state::do_check(THD *thd, set_var *var)
my_error(ER_BINLOG_MUST_BE_EMPTY, MYF(0));
return true;
}
return false;
}


bool
Sys_var_gtid_binlog_state::global_update(THD *thd, set_var *var)
{
DBUG_ASSERT(var->type == OPT_GLOBAL);

if (!var->value)
{
my_error(ER_NO_DEFAULT, MYF(0), var->var->name.str);
return true;
}

bool result;
String str, *res;
struct gtid_binlog_state_data *data;
rpl_gtid *list;
uint32 list_len;

DBUG_ASSERT(var->type == OPT_GLOBAL);

if (!(res= var->value->val_str(&str)))
return true;
if (res->length() == 0)
{
list= NULL;
Expand All @@ -2061,31 +2077,13 @@ Sys_var_gtid_binlog_state::do_check(THD *thd, set_var *var)
data->list= list;
data->list_len= list_len;
var->save_result.ptr= data;
return false;
}


bool
Sys_var_gtid_binlog_state::global_update(THD *thd, set_var *var)
{
bool res;

DBUG_ASSERT(var->type == OPT_GLOBAL);

if (!var->value)
{
my_error(ER_NO_DEFAULT, MYF(0), var->var->name.str);
return true;
}

struct gtid_binlog_state_data *data=
(struct gtid_binlog_state_data *)var->save_result.ptr;

mysql_mutex_unlock(&LOCK_global_system_variables);
res= (reset_master(thd, data->list, data->list_len, 0) != 0);
result= (reset_master(thd, data->list, data->list_len, 0) != 0);
mysql_mutex_lock(&LOCK_global_system_variables);
my_free(data->list);
my_free(data);
return res;
return result;
}


Expand Down