summaryrefslogtreecommitdiff
path: root/sql/slave.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/slave.cc')
-rw-r--r--sql/slave.cc35
1 files changed, 16 insertions, 19 deletions
diff --git a/sql/slave.cc b/sql/slave.cc
index 95818e60426..78fa7998012 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -1793,7 +1793,9 @@ past_checksum:
}
}
}
+#ifndef DBUG_OFF
after_set_capability:
+#endif
err:
if (errmsg)
@@ -2446,13 +2448,23 @@ static int init_slave_thread(THD* thd, Master_info *mi,
SLAVE_THD_TYPE thd_type)
{
DBUG_ENTER("init_slave_thread");
-#if !defined(DBUG_OFF)
- int simulate_error= 0;
-#endif
+ int simulate_error __attribute__((unused))= 0;
+ DBUG_EXECUTE_IF("simulate_io_slave_error_on_init",
+ simulate_error|= (1 << SLAVE_THD_IO););
+ DBUG_EXECUTE_IF("simulate_sql_slave_error_on_init",
+ simulate_error|= (1 << SLAVE_THD_SQL););
+ /* We must call store_globals() before doing my_net_init() */
+ if (init_thr_lock() || thd->store_globals() ||
+ my_net_init(&thd->net, 0, MYF(MY_THREAD_SPECIFIC)) ||
+ IF_DBUG(simulate_error & (1<< thd_type), 0))
+ {
+ thd->cleanup();
+ DBUG_RETURN(-1);
+ }
+
thd->system_thread = (thd_type == SLAVE_THD_SQL) ?
SYSTEM_THREAD_SLAVE_SQL : SYSTEM_THREAD_SLAVE_IO;
thd->security_ctx->skip_grants();
- my_net_init(&thd->net, 0);
/*
Adding MAX_LOG_EVENT_HEADER_LEN to the max_allowed_packet on all
slave threads, since a replication event can become this much larger
@@ -2469,17 +2481,6 @@ static int init_slave_thread(THD* thd, Master_info *mi,
thd->thread_id= thd->variables.pseudo_thread_id= thread_id++;
mysql_mutex_unlock(&LOCK_thread_count);
- DBUG_EXECUTE_IF("simulate_io_slave_error_on_init",
- simulate_error|= (1 << SLAVE_THD_IO););
- DBUG_EXECUTE_IF("simulate_sql_slave_error_on_init",
- simulate_error|= (1 << SLAVE_THD_SQL););
- if (init_thr_lock() || thd->store_globals() ||
- IF_DBUG(simulate_error & (1<< thd_type), 0))
- {
- thd->cleanup();
- DBUG_RETURN(-1);
- }
-
if (thd_type == SLAVE_THD_SQL)
THD_STAGE_INFO(thd, stage_waiting_for_the_next_event_in_relay_log);
else
@@ -3516,8 +3517,6 @@ err_during_init:
mi->rli.relay_log.description_event_for_queue= 0;
// TODO: make rpl_status part of Master_info
change_rpl_status(RPL_ACTIVE_SLAVE,RPL_IDLE_SLAVE);
- DBUG_ASSERT(thd->net.buff != 0);
- net_end(&thd->net); // destructor will not free it, because net.vio is 0
mysql_mutex_lock(&LOCK_thread_count);
THD_CHECK_SENTRY(thd);
delete thd;
@@ -3923,8 +3922,6 @@ err_during_init:
to avoid unneeded position re-init
*/
thd->temporary_tables = 0; // remove tempation from destructor to close them
- DBUG_ASSERT(thd->net.buff != 0);
- net_end(&thd->net); // destructor will not free it, because we are weird
DBUG_ASSERT(rli->sql_thd == thd);
THD_CHECK_SENTRY(thd);
rli->sql_thd= 0;