#At file:///home/andrei/MySQL/BZR/2a-23May/WL/mysql-next-mr-wl5569/ based on revid:andrei.elkin@stripped
3278 Andrei Elkin 2011-05-19
wl#5569 MTS
Support for ROWS_QUERY_LOG_EVENT is added.
It required refactoring of its handling in the canonical sequential mode.
The event life suggests its behavior similar to objects associated with Table_map,
in particural, its destoying to occur at the end-of-statement time.
Tested against existing ROWS_QUERY_LOG_EVENT feature tests incl
rpl_row_ignorable_event in both sequential and parallel mode.
@ sql/log_event.cc
cleanup of MTS code;
relocating handle_rows_query_log_event() logics into
a. do_apply_event() and
b. rli->cleanup_context().
@ sql/log_event.h
cleanup of MTS code;
@ sql/rpl_rli.cc
Deploying ROWS_QUERY_LOG_EVENT destruction in context_cleanup().
@ sql/rpl_rli.h
cleanup of MTS code;
@ sql/rpl_slave.cc
cleanup of MTS code;
@ sql/sql_binlog.cc
Simplifying ROWS_QUERY_LOG_EVENT handling in the case
of BINLOG pseudo-query.
modified:
sql/log_event.cc
sql/log_event.h
sql/rpl_rli.cc
sql/rpl_rli.h
sql/rpl_slave.cc
sql/sql_binlog.cc
=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc 2011-05-16 19:43:58 +0000
+++ b/sql/log_event.cc 2011-05-19 09:36:28 +0000
@@ -161,38 +161,6 @@ static const char *HA_ERR(int i)
}
/**
- Delay to delete the Rows_query log event until all its rows event are applied
-
- @param ev log event should be deleted
- @param rli Relay_log_info structure for the slave IO thread.
-*/
-void handle_rows_query_log_event(Log_event *ev, Relay_log_info *rli)
-{
- DBUG_ENTER("handle_rows_query_log_event");
- Log_event_type ev_type= ev->get_type_code();
-
- /* Delete the Rows_query log event after its last rows event are applied */
- if ((ev_type == WRITE_ROWS_EVENT || ev_type == DELETE_ROWS_EVENT ||
- ev_type == UPDATE_ROWS_EVENT) && rli->rows_query_ev != NULL &&
- ((Rows_log_event*) ev)->get_flags(Rows_log_event::STMT_END_F))
- {
- if (rli->rows_query_ev)
- delete rli->rows_query_ev;
- rli->rows_query_ev= NULL;
- rli->info_thd->set_query(NULL, 0);
- }
-
- /* Record the Rows_query log event until all its rows event are applied */
- if (ev_type == ROWS_QUERY_LOG_EVENT)
- {
- DBUG_ASSERT(rli->rows_query_ev == NULL);
- rli->rows_query_ev= (Rows_query_log_event*) ev;
- }
-
- DBUG_VOID_RETURN;
-}
-
-/**
Error reporting facility for Rows_log_event::do_apply_event
@param level error, warning or info
@@ -2872,26 +2840,13 @@ int Log_event::apply_event(Relay_log_inf
DBUG_ASSERT(!(rli->curr_group_seen_begin && ends_group()) ||
rli->last_assigned_worker);
- /*
- Todo: disassociate Rows_* events from the central rli.
- */
if (seq_event)
{ // rli->last_assigned_worker != NULL if BTQ but not BQT
DBUG_ASSERT(rli->curr_group_seen_begin || ends_group());
if (!c_rli->curr_group_isolated)
(void) wait_for_workers_to_finish(rli, rli->last_assigned_worker);
c_rli->curr_group_isolated= TRUE;
-
- if (get_type_code() == ROWS_QUERY_LOG_EVENT)
- {
- while (c_rli->rows_query_ev != NULL)
- {
- my_sleep(10);
- }
- c_rli->rows_query_ev= (Rows_query_log_event*) this;
- }
}
-
// getting Worker's id
if ((!(w= get_slave_worker_id(rli)) ||
DBUG_EVALUATE_IF("fault_injection_get_slave_worker", 1, 0)))
@@ -11393,16 +11348,21 @@ Rows_query_log_event::write_data_body(IO
DBUG_RETURN(write_str(file, m_rows_query, (uint) strlen(m_rows_query)));
}
-#ifndef MYSQL_CLIENT
+#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
int Rows_query_log_event::do_apply_event(Relay_log_info const *rli)
{
DBUG_ENTER("Rows_query_log_event::do_apply_event");
- DBUG_ASSERT(rli->info_thd == thd || rli->is_parallel_exec());
+ DBUG_ASSERT(rli->info_thd == thd);
/* Set query for writing Rows_query log event into binlog later.*/
thd->set_query(m_rows_query, (uint32) strlen(m_rows_query));
+
+ DBUG_ASSERT(rli->rows_query_ev == NULL);
+
+ const_cast<Relay_log_info*>(rli)->rows_query_ev= this;
+
DBUG_RETURN(0);
}
-#endif /* !MYSQL_CLIENT */
+#endif
#ifdef MYSQL_CLIENT
=== modified file 'sql/log_event.h'
--- a/sql/log_event.h 2011-05-16 19:43:58 +0000
+++ b/sql/log_event.h 2011-05-19 09:36:28 +0000
@@ -1264,8 +1264,6 @@ public:
get_type_code() == PRE_GA_UPDATE_ROWS_EVENT||
get_type_code() == PRE_GA_DELETE_ROWS_EVENT||
- get_type_code() == ROWS_QUERY_LOG_EVENT || /* TODO: make parallel */
-
get_type_code() == INCIDENT_EVENT;
}
@@ -4308,11 +4306,11 @@ public:
{
return IGNORABLE_HEADER_LEN + 1 + (uint) strlen(m_rows_query);
}
+#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
+ virtual int do_apply_event(Relay_log_info const *rli);
+#endif
private:
-#if !defined(MYSQL_CLIENT)
- virtual int do_apply_event(Relay_log_info const* rli);
-#endif
char * m_rows_query;
};
=== modified file 'sql/rpl_rli.cc'
--- a/sql/rpl_rli.cc 2011-05-16 19:43:58 +0000
+++ b/sql/rpl_rli.cc 2011-05-19 09:36:28 +0000
@@ -1056,23 +1056,13 @@ void Relay_log_info::cleanup_context(THD
trans_rollback_stmt(thd); // if a "statement transaction"
trans_rollback(thd); // if a "real transaction"
}
- /*
- MTS W/a for Rows_query_log_event.
- Cleanup of rows_query_ev at the end of the current statement.
-
- TODO: move handle_rows_query_log_event() cleanup logics into this method
- inconditionally.
- */
- if (error || is_parallel_exec())
- if (rows_query_ev)
- {
- delete rows_query_ev;
- rows_query_ev= NULL;
- info_thd->set_query(NULL, 0);
- }
-
+ if (rows_query_ev)
+ {
+ delete rows_query_ev;
+ rows_query_ev= NULL;
+ info_thd->set_query(NULL, 0);
+ }
m_table_map.clear_tables();
-
slave_close_thread_tables(thd);
if (error)
thd->mdl_context.release_transactional_locks();
=== modified file 'sql/rpl_rli.h'
--- a/sql/rpl_rli.h 2011-05-16 19:43:58 +0000
+++ b/sql/rpl_rli.h 2011-05-19 09:36:28 +0000
@@ -388,7 +388,7 @@ public:
uint tables_to_lock_count; /* RBR: Count of tables to lock */
table_mapping m_table_map; /* RBR: Mapping table-id to table */
/* RBR: Record Rows_query log event */
- volatile Rows_query_log_event* rows_query_ev; // mts w/a makes it volatile
+ Rows_query_log_event* rows_query_ev;
bool get_table_data(TABLE *table_arg, table_def **tabledef_var, TABLE **conv_table_var) const
{
=== modified file 'sql/rpl_slave.cc'
--- a/sql/rpl_slave.cc 2011-05-16 19:43:58 +0000
+++ b/sql/rpl_slave.cc 2011-05-19 09:36:28 +0000
@@ -3038,47 +3038,33 @@ static int exec_relay_log_event(THD* thd
exec_res= apply_event_and_update_pos(ev, thd, rli);
- /*
- Format_description_log_event should not be deleted because it will be
- used to read info about the relay log's format; it will be deleted when
- the SQL thread does not need it, i.e. when this thread terminates.
- */
- // if (ev->get_type_code() != FORMAT_DESCRIPTION_EVENT)
+ if ((!rli->is_parallel_exec() || !rli->curr_group_is_parallel))
{
- if ((!rli->is_parallel_exec() || !rli->curr_group_is_parallel))
+ DBUG_ASSERT(!rli->is_parallel_exec() || !rli->curr_group_is_parallel ||
+ ev->shall_skip(rli) != Log_event::EVENT_SKIP_NOT);
+
+ if (rli->curr_group_split)
{
- DBUG_ASSERT(!rli->is_parallel_exec() || !rli->curr_group_is_parallel ||
- ev->shall_skip(rli) != Log_event::EVENT_SKIP_NOT);
-
- if (rli->curr_group_split)
- {
- // the current group split status is reset
- rli->curr_group_is_parallel= TRUE;
- rli->curr_group_split= FALSE;
- }
- if (ev->get_type_code() != FORMAT_DESCRIPTION_EVENT)
- {
- /* MTS/ TODO.
-
- ROWS_QUERY_LOG_EVENT could be supported easier if
- destructing part of handle_rows_query_log_event would be merged
- with rli->cleanup_context() and the rest move into
- ROWS...::do_apply_event
- */
- if (!rli->is_parallel_exec())
- if (thd->variables.binlog_rows_query_log_events)
- handle_rows_query_log_event(ev, rli);
-
- if (ev->get_type_code() != ROWS_QUERY_LOG_EVENT)
- {
- DBUG_PRINT("info", ("Deleting the event after it has been executed"));
- delete ev;
- ev= NULL;
- }
- }
+ // the current group split status is reset
+ rli->curr_group_is_parallel= TRUE;
+ rli->curr_group_split= FALSE;
+ }
+ /*
+ Format_description_log_event should not be deleted because it will be
+ used to read info about the relay log's format; it will be deleted when
+ the SQL thread does not need it, i.e. when this thread terminates.
+ ROWS_QUERY_LOG_EVENT is destroyed at the end of the current statement
+ clean-up routine.
+ */
+ if (ev->get_type_code() != FORMAT_DESCRIPTION_EVENT &&
+ ev->get_type_code() != ROWS_QUERY_LOG_EVENT)
+ {
+ DBUG_PRINT("info", ("Deleting the event after it has been executed"));
+ delete ev;
+ ev= NULL;
}
}
-
+
/*
update_log_pos failed: this should not happen, so we don't
retry.
=== modified file 'sql/sql_binlog.cc'
--- a/sql/sql_binlog.cc 2010-12-02 13:44:21 +0000
+++ b/sql/sql_binlog.cc 2011-05-19 09:36:28 +0000
@@ -284,16 +284,14 @@ void mysql_client_binlog_statement(THD*
will be used to read info about the relay log's format; it
will be deleted when the SQL thread does not need it,
i.e. when this thread terminates.
+ ROWS_QUERY_LOG_EVENT if present in rli is deleted at the end
+ of the event.
*/
- if (ev->get_type_code() != FORMAT_DESCRIPTION_EVENT)
+ if (ev->get_type_code() != FORMAT_DESCRIPTION_EVENT &&
+ ev->get_type_code() != ROWS_QUERY_LOG_EVENT)
{
- if (thd->variables.binlog_rows_query_log_events)
- handle_rows_query_log_event(ev, rli);
- if (ev->get_type_code() != ROWS_QUERY_LOG_EVENT)
- {
- delete ev;
- ev= NULL;
- }
+ delete ev;
+ ev= NULL;
}
if (err)
{
Attachment: [text/bzr-bundle] bzr/andrei.elkin@oracle.com-20110519093628-zldw938goh2lr2in.bundle
| Thread |
|---|
| • bzr commit into mysql-next-mr-wl5569 branch (andrei.elkin:3278) WL#5569 | Andrei Elkin | 19 May |