summaryrefslogtreecommitdiff
path: root/sql/wsrep_thd.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/wsrep_thd.cc')
-rw-r--r--sql/wsrep_thd.cc63
1 files changed, 28 insertions, 35 deletions
diff --git a/sql/wsrep_thd.cc b/sql/wsrep_thd.cc
index 2b4980ae05f..7ef31171846 100644
--- a/sql/wsrep_thd.cc
+++ b/sql/wsrep_thd.cc
@@ -89,32 +89,6 @@ void wsrep_client_rollback(THD *thd)
#define NUMBER_OF_FIELDS_TO_IDENTIFY_COORDINATOR 1
#define NUMBER_OF_FIELDS_TO_IDENTIFY_WORKER 2
-//#include "rpl_info_factory.h"
-
-#ifdef NOT_USED
-static Relay_log_info* wsrep_relay_log_init(const char* log_fname)
-{
-
- /* MySQL 5.6 version has rli factory: */
-#ifdef MYSQL_56
- uint rli_option = INFO_REPOSITORY_DUMMY;
- Relay_log_info *rli= NULL;
- rli = Rpl_info_factory::create_rli(rli_option, false);
- rli->set_rli_description_event(
- new Format_description_log_event(BINLOG_VERSION));
-#endif
- Relay_log_info* rli= new Relay_log_info(false);
- rli->sql_driver_thd= current_thd;
-
- rli->no_storage= true;
- rli->relay_log.description_event_for_exec=
- new Format_description_log_event(4);
-
- return rli;
-}
-#endif
-
-class Master_info;
static rpl_group_info* wsrep_relay_group_init(const char* log_fname)
{
@@ -126,13 +100,27 @@ static rpl_group_info* wsrep_relay_group_init(const char* log_fname)
rli->relay_log.description_event_for_exec=
new Format_description_log_event(4);
}
- static LEX_STRING dbname= { C_STRING_WITH_LEN("mysql") };
- rli->mi = new Master_info( &dbname, false);
- //rli->mi = new Master_info( &(C_STRING_WITH_LEN("wsrep")), false);
+ static LEX_STRING connection_name= { C_STRING_WITH_LEN("wsrep") };
+
+ /*
+ Master_info's constructor initializes rpl_filter by either an already
+ constructed Rpl_filter object from global 'rpl_filters' list if the
+ specified connection name is same, or it constructs a new Rpl_filter
+ object and adds it to rpl_filters. This object is later destructed by
+ Mater_info's destructor by looking it up based on connection name in
+ rpl_filters list.
+
+ However, since all Master_info objects created here would share same
+ connection name ("wsrep"), destruction of any of the existing Master_info
+ objects (in wsrep_return_from_bf_mode()) would free rpl_filter referenced
+ by any/all existing Master_info objects.
- rli->mi->rpl_filter = new Rpl_filter;
- copy_filter_setting(rli->mi->rpl_filter, get_or_create_rpl_filter("", 0));
+ In order to avoid that, we have added a check in Master_info's destructor
+ to not free the "wsrep" rpl_filter. It will eventually be freed by
+ free_all_rpl_filters() when server terminates.
+ */
+ rli->mi = new Master_info(&connection_name, false);
rli->sql_driver_thd= current_thd;
@@ -154,9 +142,11 @@ static void wsrep_prepare_bf_thd(THD *thd, struct wsrep_thd_shadow* shadow)
else
thd->variables.option_bits&= ~(OPTION_BIN_LOG);
- //if (!thd->wsrep_rli) thd->wsrep_rli= wsrep_relay_log_init("wsrep_relay");
if (!thd->wsrep_rgi) thd->wsrep_rgi= wsrep_relay_group_init("wsrep_relay");
- // thd->wsrep_rli->info_thd = thd;
+
+ /* thd->system_thread_info.rpl_sql_info isn't initialized. */
+ thd->system_thread_info.rpl_sql_info=
+ new rpl_sql_thread_info(thd->wsrep_rgi->rli->mi->rpl_filter);
thd->wsrep_exec_mode= REPL_RECV;
thd->net.vio= 0;
@@ -180,12 +170,11 @@ static void wsrep_return_from_bf_mode(THD *thd, struct wsrep_thd_shadow* shadow)
thd->variables.tx_isolation = shadow->tx_isolation;
thd->reset_db(shadow->db, shadow->db_length);
- delete thd->wsrep_rgi->rli->mi->rpl_filter;
+ delete thd->system_thread_info.rpl_sql_info;
delete thd->wsrep_rgi->rli->mi;
delete thd->wsrep_rgi->rli;
delete thd->wsrep_rgi;
thd->wsrep_rgi = NULL;
-;
}
void wsrep_replay_transaction(THD *thd)
@@ -283,6 +272,10 @@ void wsrep_replay_transaction(THD *thd)
WSREP_ERROR("trx_replay failed for: %d, query: %s",
rcode, thd->query() ? thd->query() : "void");
/* we're now in inconsistent state, must abort */
+
+ /* http://bazaar.launchpad.net/~codership/codership-mysql/5.6/revision/3962#sql/wsrep_thd.cc */
+ mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
+
unireg_abort(1);
break;
}