1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

MWL#234: After-review fixes, including better names for the new system variables.

This commit is contained in:
unknown
2011-08-12 13:18:34 +02:00
parent c4d69f1775
commit b1a13cb15a
12 changed files with 178 additions and 160 deletions

View File

@ -671,7 +671,7 @@ Log_event::Log_event(THD* thd_arg, uint16 flags_arg, bool using_trans)
when= thd->start_time;
cache_stmt= using_trans;
flags= flags_arg |
(thd->options & OPTION_DO_NOT_REPLICATE ? LOG_EVENT_DO_NOT_REPLICATE_F : 0);
(thd->options & OPTION_SKIP_REPLICATION ? LOG_EVENT_SKIP_REPLICATION_F : 0);
}
@ -828,8 +828,8 @@ Log_event::do_shall_skip(Relay_log_info *rli)
rli->slave_skip_counter));
if ((server_id == ::server_id && !rli->replicate_same_server_id) ||
(rli->slave_skip_counter == 1 && rli->is_in_group()) ||
(flags & LOG_EVENT_DO_NOT_REPLICATE_F
&& opt_replicate_ignore_do_not_replicate))
(flags & LOG_EVENT_SKIP_REPLICATION_F
&& !opt_replicate_events_marked_for_skip))
return EVENT_SKIP_IGNORE;
if (rli->slave_skip_counter > 0)
return EVENT_SKIP_COUNT;
@ -3488,11 +3488,11 @@ Query_log_event::do_shall_skip(Relay_log_info *rli)
DBUG_ASSERT(query && q_len > 0);
/*
An event skipped due to @@do_not_replicate must not be counted towards the
An event skipped due to @@skip_replication must not be counted towards the
number of events to be skipped due to @@sql_slave_skip_counter.
*/
if (flags & LOG_EVENT_DO_NOT_REPLICATE_F &&
opt_replicate_ignore_do_not_replicate)
if (flags & LOG_EVENT_SKIP_REPLICATION_F &&
!opt_replicate_events_marked_for_skip)
DBUG_RETURN(Log_event::EVENT_SKIP_IGNORE);
if (rli->slave_skip_counter > 0)
@ -9792,7 +9792,7 @@ st_print_event_info::st_print_event_info()
auto_increment_increment(0),auto_increment_offset(0), charset_inited(0),
lc_time_names_number(~0),
charset_database_number(ILLEGAL_CHARSET_INFO_NUMBER),
thread_id(0), thread_id_printed(false), do_not_replicate(0),
thread_id(0), thread_id_printed(false), skip_replication(0),
base64_output_mode(BASE64_OUTPUT_UNSPEC), printed_fd_event(FALSE)
{
/*

View File

@ -491,16 +491,16 @@ struct sql_ex_info
#define LOG_EVENT_RELAY_LOG_F 0x40
/**
@def LOG_EVENT_DO_NOT_REPLICATE_F
@def LOG_EVENT_SKIP_REPLICATION_F
Flag set by application creating the event (with @@do_not_replicate); the
Flag set by application creating the event (with @@skip_replication); the
slave will skip replication of such events if
--replicate-ignore-do-not-replicate is set.
--replicate-events-marked-for-skip is false.
This is a MariaDB flag; we allocate it from the end of the available
values to reduce risk of conflict with new MySQL flags.
*/
#define LOG_EVENT_DO_NOT_REPLICATE_F 0x8000
#define LOG_EVENT_SKIP_REPLICATION_F 0x8000
/**
@ -670,10 +670,10 @@ typedef struct st_print_event_info
uint thread_id;
bool thread_id_printed;
/*
Track when @@do_not_replicate changes so we need to output a SET
Track when @@skip_replication changes so we need to output a SET
statement for it.
*/
int do_not_replicate;
int skip_replication;
st_print_event_info();
@ -929,7 +929,7 @@ public:
/**
Some 16 flags. See the definitions above for LOG_EVENT_TIME_F,
LOG_EVENT_FORCED_ROTATE_F, LOG_EVENT_THREAD_SPECIFIC_F,
LOG_EVENT_SUPPRESS_USE_F, and LOG_EVENT_DO_NOT_REPLICATE_F for notes.
LOG_EVENT_SUPPRESS_USE_F, and LOG_EVENT_SKIP_REPLICATION_F for notes.
*/
uint16 flags;
@ -3933,8 +3933,8 @@ public:
DBUG_PRINT("enter", ("m_incident: %d", m_incident));
m_message.str= NULL; /* Just as a precaution */
m_message.length= 0;
/* Replicate the incident irregardless of @@do_not_replicate. */
flags&= ~LOG_EVENT_DO_NOT_REPLICATE_F;
/* Replicate the incident irregardless of @@skip_replication. */
flags&= ~LOG_EVENT_SKIP_REPLICATION_F;
DBUG_VOID_RETURN;
}
@ -3944,8 +3944,8 @@ public:
DBUG_ENTER("Incident_log_event::Incident_log_event");
DBUG_PRINT("enter", ("m_incident: %d", m_incident));
m_message= msg;
/* Replicate the incident irregardless of @@do_not_replicate. */
flags&= ~LOG_EVENT_DO_NOT_REPLICATE_F;
/* Replicate the incident irregardless of @@skip_replication. */
flags&= ~LOG_EVENT_SKIP_REPLICATION_F;
DBUG_VOID_RETURN;
}
#endif

View File

@ -504,7 +504,7 @@ protected:
*/
#define TMP_TABLE_FORCE_MYISAM (ULL(1) << 32)
#define OPTION_PROFILING (ULL(1) << 33)
#define OPTION_DO_NOT_REPLICATE (ULL(1) << 34) // THD, user
#define OPTION_SKIP_REPLICATION (ULL(1) << 34) // THD, user
@ -2065,7 +2065,7 @@ extern my_bool opt_old_style_user_limits, trust_function_creators;
extern uint opt_crash_binlog_innodb;
extern char *shared_memory_base_name, *mysqld_unix_port;
extern my_bool opt_enable_shared_memory;
extern my_bool opt_replicate_ignore_do_not_replicate;
extern my_bool opt_replicate_events_marked_for_skip;
extern char *default_tz_name;
#endif /* MYSQL_SERVER */
#if defined MYSQL_SERVER || defined INNODB_COMPATIBILITY_HOOKS

View File

@ -553,7 +553,7 @@ uint opt_large_page_size= 0;
uint opt_debug_sync_timeout= 0;
#endif /* defined(ENABLED_DEBUG_SYNC) */
my_bool opt_old_style_user_limits= 0, trust_function_creators= 0;
my_bool opt_replicate_ignore_do_not_replicate;
my_bool opt_replicate_events_marked_for_skip;
/*
True if there is at least one per-hour limit for some user, so we should
@ -5935,6 +5935,7 @@ enum options_mysqld
OPT_SAFEMALLOC_MEM_LIMIT, OPT_REPLICATE_DO_TABLE,
OPT_REPLICATE_IGNORE_TABLE, OPT_REPLICATE_WILD_DO_TABLE,
OPT_REPLICATE_WILD_IGNORE_TABLE, OPT_REPLICATE_SAME_SERVER_ID,
OPT_REPLICATE_EVENTS_MARKED_FOR_SKIP,
OPT_DISCONNECT_SLAVE_EVENT_COUNT, OPT_TC_HEURISTIC_RECOVER,
OPT_ABORT_SLAVE_EVENT_COUNT,
OPT_LOG_BIN_TRUST_FUNCTION_CREATORS,
@ -6087,8 +6088,7 @@ enum options_mysqld
OPT_IGNORE_BUILTIN_INNODB,
OPT_BINLOG_DIRECT_NON_TRANS_UPDATE,
OPT_DEFAULT_CHARACTER_SET_OLD,
OPT_MAX_LONG_DATA_SIZE,
OPT_REPLICATE_IGNORE_DO_NOT_REPLICATE
OPT_MAX_LONG_DATA_SIZE
};
@ -6785,11 +6785,12 @@ each time the SQL thread starts.",
"cross database updates. If you need cross database updates to work, "
"make sure you have 3.23.28 or later, and use replicate-wild-ignore-"
"table=db_name.%. ", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"replicate-ignore-do-not-replicate", OPT_REPLICATE_IGNORE_DO_NOT_REPLICATE,
"Tells the slave thread not to replicate events that were created with"
"@@do_not_replicat=1.", &opt_replicate_ignore_do_not_replicate,
&opt_replicate_ignore_do_not_replicate, 0, GET_BOOL, NO_ARG,
0, 0, 0 ,0, 0, 0},
{"replicate-events-marked-for-skip", OPT_REPLICATE_EVENTS_MARKED_FOR_SKIP,
"Tells the slave thread to replicate events that were created with"
"@@skip_replication=1. Default true. If set to false, such events will not"
"be replicated.", &opt_replicate_events_marked_for_skip,
&opt_replicate_events_marked_for_skip, 0, GET_BOOL, NO_ARG,
1, 0, 0 ,0, 0, 0},
{"replicate-ignore-table", OPT_REPLICATE_IGNORE_TABLE,
"Tells the slave thread to not replicate to the specified table. To specify "
"more than one table to ignore, use the directive multiple times, once for "

View File

@ -117,7 +117,7 @@ static bool set_option_log_bin_bit(THD *thd, set_var *var);
static bool set_option_autocommit(THD *thd, set_var *var);
static int check_log_update(THD *thd, set_var *var);
static bool set_log_update(THD *thd, set_var *var);
static int check_do_not_replicate(THD *thd, set_var *var);
static int check_skip_replication(THD *thd, set_var *var);
static int check_pseudo_thread_id(THD *thd, set_var *var);
void fix_binlog_format_after_update(THD *thd, enum_var_type type);
static void fix_low_priority_updates(THD *thd, enum_var_type type);
@ -831,10 +831,20 @@ static sys_var_thd_bit sys_profiling(&vars, "profiling", NULL,
static sys_var_thd_ulong sys_profiling_history_size(&vars, "profiling_history_size",
&SV::profiling_history_size);
#endif
static sys_var_thd_bit sys_do_not_replicate(&vars, "do_not_replicate",
check_do_not_replicate,
/*
When this is set by a connection, binlogged events will be marked with a
corresponding flag. The slave can be configured to not replicate events
so marked.
In the binlog dump thread on the master, this variable is re-used for a
related purpose: The slave sets this flag when connecting to the master to
request that the master filter out (ie. not send) any events with the flag
set, thus saving network traffic on events that would be ignored by the
slave anyway.
*/
static sys_var_thd_bit sys_skip_replication(&vars, "skip_replication",
check_skip_replication,
set_option_bit,
OPTION_DO_NOT_REPLICATE);
OPTION_SKIP_REPLICATION);
/* Local state variables */
@ -912,10 +922,10 @@ static sys_var_thd_set sys_log_slow_verbosity(&vars,
&SV::log_slow_verbosity,
&log_slow_verbosity_typelib);
#ifdef HAVE_REPLICATION
static sys_var_replicate_ignore_do_not_replicate
sys_replicate_ignore_do_not_replicate(&vars,
"replicate_ignore_do_not_replicate",
&opt_replicate_ignore_do_not_replicate);
static sys_var_replicate_events_marked_for_skip
sys_replicate_events_marked_for_skip(&vars,
"replicate_events_marked_for_skip",
&opt_replicate_events_marked_for_skip);
#endif
/* Global read-only variable containing hostname */
@ -3279,10 +3289,10 @@ static bool set_log_update(THD *thd, set_var *var)
}
static int check_do_not_replicate(THD *thd, set_var *var)
static int check_skip_replication(THD *thd, set_var *var)
{
/*
We must not change @@do_not_replicate in the middle of a transaction or
We must not change @@skip_replication in the middle of a transaction or
statement, as that could result in only part of the transaction / statement
being replicated.
(This would be particularly serious if we were to replicate eg.
@ -4443,11 +4453,11 @@ sys_var_event_scheduler::update(THD *thd, set_var *var)
#ifdef HAVE_REPLICATION
bool sys_var_replicate_ignore_do_not_replicate::update(THD *thd, set_var *var)
bool sys_var_replicate_events_marked_for_skip::update(THD *thd, set_var *var)
{
bool result;
int thread_mask;
DBUG_ENTER("sys_var_replicate_ignore_do_not_replicate::update");
DBUG_ENTER("sys_var_replicate_events_marked_for_skip::update");
/* Slave threads must be stopped to change the variable. */
pthread_mutex_lock(&LOCK_active_mi);

View File

@ -1286,17 +1286,17 @@ public:
#ifdef HAVE_REPLICATION
/**
Handler for setting the system variable --replicate-ignore-do-not-replicate.
Handler for setting the system variable --replicate-events-marked-for-skip.
*/
class sys_var_replicate_ignore_do_not_replicate :public sys_var_bool_ptr
class sys_var_replicate_events_marked_for_skip :public sys_var_bool_ptr
{
public:
sys_var_replicate_ignore_do_not_replicate(sys_var_chain *chain,
const char *name_arg,
my_bool *value_arg) :
sys_var_replicate_events_marked_for_skip(sys_var_chain *chain,
const char *name_arg,
my_bool *value_arg) :
sys_var_bool_ptr(chain, name_arg, value_arg) {};
~sys_var_replicate_ignore_do_not_replicate() {};
~sys_var_replicate_events_marked_for_skip() {};
bool update(THD *thd, set_var *var);
};
#endif

View File

@ -1177,18 +1177,18 @@ when it try to get the value of TIME_ZONE global variable from master.";
}
/*
Request the master to filter away events with the @@do_not_replicate flag
set, if we are running with --replicate-ignore-do_not_replicate=1.
Request the master to filter away events with the @@skip_replication flag
set, if we are running with --replicate-events-marked-for-skip=0.
*/
if (opt_replicate_ignore_do_not_replicate)
if (!opt_replicate_events_marked_for_skip)
{
if (!mysql_real_query(mysql, STRING_WITH_LEN("SET do_not_replicate=1")))
if (mysql_real_query(mysql, STRING_WITH_LEN("SET skip_replication=1")))
{
err_code= mysql_errno(mysql);
if (is_network_error(err_code))
{
mi->report(ERROR_LEVEL, err_code,
"Setting master-side filtering of @@do_not_replicate failed "
"Setting master-side filtering of @@skip_replication failed "
"with error: %s", mysql_error(mysql));
goto network_err;
}
@ -1196,15 +1196,24 @@ when it try to get the value of TIME_ZONE global variable from master.";
{
/*
The master is older than the slave and does not support the
@@do_not_replicate feature.
@@skip_replication feature.
This is not a problem, as such master will not generate events with
the @@do_not_replicate flag set in the first place. We will still
the @@skip_replication flag set in the first place. We will still
do slave-side filtering of such events though, to handle the (rare)
case of downgrading a master and receiving old events generated from
before the downgrade with the @@do_not_replicate flag set.
before the downgrade with the @@skip_replication flag set.
*/
DBUG_PRINT("info", ("Old master does not support master-side filtering "
"of @@do_not_replicate events."));
"of @@skip_replication events."));
}
else
{
/* Fatal error */
errmsg= "The slave I/O thread stops because a fatal error is "
"encountered when it tries to request filtering of events marked "
"with the @@skip_replication flag.";
sprintf(err_buff, "%s Error: %s", errmsg, mysql_error(mysql));
goto err;
}
}
}
@ -2146,8 +2155,8 @@ int apply_event_and_update_pos(Log_event* ev, THD* thd, Relay_log_info* rli)
thd->lex->current_select= 0;
if (!ev->when)
ev->when= my_time(0);
thd->options= (thd->options & ~OPTION_DO_NOT_REPLICATE) |
(ev->flags & LOG_EVENT_DO_NOT_REPLICATE_F ? OPTION_DO_NOT_REPLICATE : 0);
thd->options= (thd->options & ~OPTION_SKIP_REPLICATION) |
(ev->flags & LOG_EVENT_SKIP_REPLICATION_F ? OPTION_SKIP_REPLICATION : 0);
ev->thd = thd; // because up to this point, ev->thd == 0
int reason= ev->shall_skip(rli);
@ -3627,7 +3636,6 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
buf[EVENT_TYPE_OFFSET] != FORMAT_DESCRIPTION_EVENT /* a way to escape */)
DBUG_RETURN(queue_old_event(mi,buf,event_len));
LINT_INIT(inc_pos);
pthread_mutex_lock(&mi->data_lock);
switch (buf[EVENT_TYPE_OFFSET]) {
@ -3702,7 +3710,7 @@ static int queue_event(Master_info* mi,const char* buf, ulong event_len)
}
/*
If we filter events master-side (eg. @@do_not_replicate), we will see holes
If we filter events master-side (eg. @@skip_replication), we will see holes
in the event positions from the master. If we see such a hole, adjust
mi->master_log_pos accordingly so we maintain the correct position (for
reconnect, MASTER_POS_WAIT(), etc.)

View File

@ -33,7 +33,7 @@
void mysql_client_binlog_statement(THD* thd)
{
ulonglong save_do_not_replicate;
ulonglong save_skip_replication;
DBUG_ENTER("mysql_client_binlog_statement");
DBUG_PRINT("info",("binlog base64: '%*s'",
(int) (thd->lex->comment.length < 2048 ?
@ -214,15 +214,15 @@ void mysql_client_binlog_statement(THD* thd)
reporting.
*/
#if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION)
save_do_not_replicate= thd->options & OPTION_DO_NOT_REPLICATE;
thd->options= (thd->options & ~OPTION_DO_NOT_REPLICATE) |
(ev->flags & LOG_EVENT_DO_NOT_REPLICATE_F ?
OPTION_DO_NOT_REPLICATE : 0);
save_skip_replication= thd->options & OPTION_SKIP_REPLICATION;
thd->options= (thd->options & ~OPTION_SKIP_REPLICATION) |
(ev->flags & LOG_EVENT_SKIP_REPLICATION_F ?
OPTION_SKIP_REPLICATION : 0);
err= ev->apply_event(rli);
thd->options= (thd->options & ~OPTION_DO_NOT_REPLICATE) |
save_do_not_replicate;
thd->options= (thd->options & ~OPTION_SKIP_REPLICATION) |
save_skip_replication;
#else
err= 0;
#endif

View File

@ -349,13 +349,17 @@ send_event_to_slave(THD *thd, NET *net, String* const packet)
thd_proc_info(thd, "Sending binlog event to slave");
/*
Skip events with the @@do_not_replicate flag set, if slave requested
Skip events with the @@skip_replication flag set, if slave requested
skipping of such events.
*/
if (thd->options & OPTION_DO_NOT_REPLICATE)
if (thd->options & OPTION_SKIP_REPLICATION)
{
/*
The first byte of the packet is a '\0' to distinguish it from an error
packet. So the actual event starts at offset +1.
*/
uint16 flags= uint2korr(&((*packet)[FLAGS_OFFSET+1]));
if (flags & LOG_EVENT_DO_NOT_REPLICATE_F)
if (flags & LOG_EVENT_SKIP_REPLICATION_F)
return NULL;
}