Skip to content

Commit 30d7860

Browse files
author
Sergei Golubchik
committed
MDEV-6459 max_relay_log_size and sql_slave_skip_counter misbehave on PPC64
make slave_skip_counter and max_relay_log_size ulonglong (sysvars should generally never be ulong)
1 parent b2c54a9 commit 30d7860

File tree

4 files changed

+45
-52
lines changed

4 files changed

+45
-52
lines changed

sql/rpl_rli.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,10 +251,11 @@ class Relay_log_info : public Slave_reporting_capability
251251
errors, and have been manually applied by DBA already.
252252
Must be ulong as it's refered to from set_var.cc
253253
*/
254-
volatile ulong slave_skip_counter;
254+
volatile ulonglong slave_skip_counter;
255+
ulonglong max_relay_log_size;
256+
255257
volatile ulong abort_pos_wait; /* Incremented on change master */
256258
volatile ulong slave_run_id; /* Incremented on slave start */
257-
ulong max_relay_log_size;
258259
mysql_mutex_t log_space_lock;
259260
mysql_cond_t log_space_cond;
260261
/*

sql/sql_class.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,14 @@ typedef struct system_variables
519519
ulonglong sortbuff_size;
520520
ulonglong group_concat_max_len;
521521
ulonglong default_regex_flags;
522+
523+
/**
524+
Place holders to store Multi-source variables in sys_var.cc during
525+
update and show of variables.
526+
*/
527+
ulonglong slave_skip_counter;
528+
ulonglong max_relay_log_size;
529+
522530
ha_rows select_limit;
523531
ha_rows max_join_size;
524532
ha_rows expensive_subquery_limit;
@@ -587,12 +595,6 @@ typedef struct system_variables
587595
*/
588596
uint32 gtid_domain_id;
589597
uint64 gtid_seq_no;
590-
/**
591-
Place holders to store Multi-source variables in sys_var.cc during
592-
update and show of variables.
593-
*/
594-
ulong slave_skip_counter;
595-
ulong max_relay_log_size;
596598

597599
/**
598600
Default transaction access mode. READ ONLY (true) or READ WRITE (false).

sql/sys_vars.cc

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4248,11 +4248,11 @@ static Sys_var_uint Sys_slave_net_timeout(
42484248
Return 0 + warning if it doesn't exist
42494249
*/
42504250

4251-
ulong Sys_var_multi_source_ulong::
4252-
get_master_info_ulong_value(THD *thd, ptrdiff_t offset)
4251+
ulonglong Sys_var_multi_source_ulonglong::
4252+
get_master_info_ulonglong_value(THD *thd, ptrdiff_t offset)
42534253
{
42544254
Master_info *mi;
4255-
ulong res= 0; // Default value
4255+
ulonglong res= 0; // Default value
42564256
mysql_mutex_unlock(&LOCK_global_system_variables);
42574257
mysql_mutex_lock(&LOCK_active_mi);
42584258
mi= master_info_index->
@@ -4261,7 +4261,7 @@ get_master_info_ulong_value(THD *thd, ptrdiff_t offset)
42614261
if (mi)
42624262
{
42634263
mysql_mutex_lock(&mi->rli.data_lock);
4264-
res= *((ulong*) (((uchar*) mi) + master_info_offset));
4264+
res= *((ulonglong*) (((uchar*) mi) + master_info_offset));
42654265
mysql_mutex_unlock(&mi->rli.data_lock);
42664266
}
42674267
mysql_mutex_unlock(&LOCK_active_mi);
@@ -4273,7 +4273,7 @@ get_master_info_ulong_value(THD *thd, ptrdiff_t offset)
42734273
bool update_multi_source_variable(sys_var *self_var, THD *thd,
42744274
enum_var_type type)
42754275
{
4276-
Sys_var_multi_source_ulong *self= (Sys_var_multi_source_ulong*) self_var;
4276+
Sys_var_multi_source_ulonglong *self= (Sys_var_multi_source_ulonglong*) self_var;
42774277
bool result= true;
42784278
Master_info *mi;
42794279

@@ -4310,16 +4310,12 @@ static bool update_slave_skip_counter(sys_var *self, THD *thd, Master_info *mi)
43104310
return false;
43114311
}
43124312

4313-
4314-
static Sys_var_multi_source_ulong
4315-
Sys_slave_skip_counter("sql_slave_skip_counter",
4316-
"Skip the next N events from the master log",
4317-
SESSION_VAR(slave_skip_counter),
4318-
NO_CMD_LINE,
4319-
my_offsetof(Master_info, rli.slave_skip_counter),
4320-
VALID_RANGE(0, UINT_MAX), DEFAULT(0), BLOCK_SIZE(1),
4321-
ON_UPDATE(update_slave_skip_counter));
4322-
4313+
static Sys_var_multi_source_ulonglong Sys_slave_skip_counter(
4314+
"sql_slave_skip_counter", "Skip the next N events from the master log",
4315+
SESSION_VAR(slave_skip_counter), NO_CMD_LINE,
4316+
MASTER_INFO_VAR(rli.slave_skip_counter),
4317+
VALID_RANGE(0, UINT_MAX), DEFAULT(0), BLOCK_SIZE(1),
4318+
ON_UPDATE(update_slave_skip_counter));
43234319

43244320
static bool update_max_relay_log_size(sys_var *self, THD *thd, Master_info *mi)
43254321
{
@@ -4328,17 +4324,14 @@ static bool update_max_relay_log_size(sys_var *self, THD *thd, Master_info *mi)
43284324
return false;
43294325
}
43304326

4331-
static Sys_var_multi_source_ulong
4332-
Sys_max_relay_log_size( "max_relay_log_size",
4333-
"relay log will be rotated automatically when the "
4334-
"size exceeds this value. If 0 are startup, it's "
4335-
"set to max_binlog_size",
4336-
SESSION_VAR(max_relay_log_size),
4337-
CMD_LINE(REQUIRED_ARG),
4338-
my_offsetof(Master_info, rli.max_relay_log_size),
4339-
VALID_RANGE(0, 1024L*1024*1024), DEFAULT(0),
4340-
BLOCK_SIZE(IO_SIZE),
4341-
ON_UPDATE(update_max_relay_log_size));
4327+
static Sys_var_multi_source_ulonglong Sys_max_relay_log_size(
4328+
"max_relay_log_size",
4329+
"relay log will be rotated automatically when the size exceeds this "
4330+
"value. If 0 are startup, it's set to max_binlog_size",
4331+
SESSION_VAR(max_relay_log_size), CMD_LINE(REQUIRED_ARG),
4332+
MASTER_INFO_VAR(rli.max_relay_log_size),
4333+
VALID_RANGE(0, 1024L*1024*1024), DEFAULT(0), BLOCK_SIZE(IO_SIZE),
4334+
ON_UPDATE(update_max_relay_log_size));
43424335

43434336
static Sys_var_charptr Sys_slave_skip_errors(
43444337
"slave_skip_errors", "Tells the slave thread to continue "

sql/sys_vars.h

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1993,7 +1993,8 @@ class Sys_var_replicate_events_marked_for_skip: public Sys_var_enum
19931993
like sql_slave_skip_counter are GLOBAL.
19941994
*/
19951995

1996-
class Sys_var_multi_source_ulong;
1996+
#define MASTER_INFO_VAR(X) my_offsetof(Master_info, X), sizeof(((Master_info *)0x10)->X)
1997+
class Sys_var_multi_source_ulonglong;
19971998
class Master_info;
19981999

19992000
typedef bool (*on_multi_source_update_function)(sys_var *self, THD *thd,
@@ -2002,31 +2003,27 @@ bool update_multi_source_variable(sys_var *self,
20022003
THD *thd, enum_var_type type);
20032004

20042005

2005-
class Sys_var_multi_source_ulong :public Sys_var_ulong
2006+
class Sys_var_multi_source_ulonglong :public Sys_var_ulonglong
20062007
{
20072008
ptrdiff_t master_info_offset;
20082009
on_multi_source_update_function update_multi_source_variable_func;
20092010
public:
2010-
Sys_var_multi_source_ulong(const char *name_arg,
2011+
Sys_var_multi_source_ulonglong(const char *name_arg,
20112012
const char *comment, int flag_args,
20122013
ptrdiff_t off, size_t size,
20132014
CMD_LINE getopt,
20142015
ptrdiff_t master_info_offset_arg,
2015-
ulong min_val, ulong max_val, ulong def_val,
2016-
uint block_size,
2016+
size_t master_info_arg_size,
2017+
ulonglong min_val, ulonglong max_val,
2018+
ulonglong def_val, uint block_size,
20172019
on_multi_source_update_function on_update_func)
2018-
:Sys_var_ulong(name_arg, comment, flag_args, off, size,
2019-
getopt, min_val, max_val, def_val, block_size,
2020-
0, VARIABLE_NOT_IN_BINLOG, 0, update_multi_source_variable),
2020+
:Sys_var_ulonglong(name_arg, comment, flag_args, off, size,
2021+
getopt, min_val, max_val, def_val, block_size,
2022+
0, VARIABLE_NOT_IN_BINLOG, 0, update_multi_source_variable),
20212023
master_info_offset(master_info_offset_arg),
20222024
update_multi_source_variable_func(on_update_func)
20232025
{
2024-
}
2025-
bool session_update(THD *thd, set_var *var)
2026-
{
2027-
session_var(thd, ulong)= (ulong) (var->save_result.ulonglong_value);
2028-
/* Value should be moved to multi_master in on_update_func */
2029-
return false;
2026+
SYSVAR_ASSERT(master_info_arg_size == size);
20302027
}
20312028
bool global_update(THD *thd, set_var *var)
20322029
{
@@ -2039,17 +2036,17 @@ class Sys_var_multi_source_ulong :public Sys_var_ulong
20392036
}
20402037
uchar *session_value_ptr(THD *thd,LEX_STRING *base)
20412038
{
2042-
ulong *tmp, res;
2043-
tmp= (ulong*) (((uchar*)&(thd->variables)) + offset);
2044-
res= get_master_info_ulong_value(thd, master_info_offset);
2039+
ulonglong *tmp, res;
2040+
tmp= (ulonglong*) (((uchar*)&(thd->variables)) + offset);
2041+
res= get_master_info_ulonglong_value(thd, master_info_offset);
20452042
*tmp= res;
20462043
return (uchar*) tmp;
20472044
}
20482045
uchar *global_value_ptr(THD *thd, LEX_STRING *base)
20492046
{
20502047
return session_value_ptr(thd, base);
20512048
}
2052-
ulong get_master_info_ulong_value(THD *thd, ptrdiff_t offset);
2049+
ulonglong get_master_info_ulonglong_value(THD *thd, ptrdiff_t offset);
20532050
bool update_variable(THD *thd, Master_info *mi)
20542051
{
20552052
return update_multi_source_variable_func(this, thd, mi);

0 commit comments

Comments
 (0)