summaryrefslogtreecommitdiff
path: root/sql/rpl_mi.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/rpl_mi.cc')
-rw-r--r--sql/rpl_mi.cc30
1 files changed, 20 insertions, 10 deletions
diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc
index 3e73d80ef48..b03db07e443 100644
--- a/sql/rpl_mi.cc
+++ b/sql/rpl_mi.cc
@@ -1084,6 +1084,7 @@ bool Master_info_index::init_all_master_info()
int err_num= 0, succ_num= 0; // The number of success read Master_info
char sign[MAX_CONNECTION_NAME+1];
File index_file_nr;
+ THD *thd;
DBUG_ENTER("init_all_master_info");
DBUG_ASSERT(master_info_index);
@@ -1115,6 +1116,10 @@ bool Master_info_index::init_all_master_info()
DBUG_RETURN(1);
}
+ thd= new THD; /* Needed by start_slave_threads */
+ thd->thread_stack= (char*) &thd;
+ thd->store_globals();
+
reinit_io_cache(&index_file, READ_CACHE, 0L,0,0);
while (!init_strvar_from_file(sign, sizeof(sign),
&index_file, NULL))
@@ -1130,7 +1135,7 @@ bool Master_info_index::init_all_master_info()
mi->error())
{
delete mi;
- DBUG_RETURN(1);
+ goto error;
}
init_thread_mask(&thread_mask,mi,0 /*not inverse*/);
@@ -1159,7 +1164,7 @@ bool Master_info_index::init_all_master_info()
{
/* Master_info is not in HASH; Add it */
if (master_info_index->add_master_info(mi, FALSE))
- DBUG_RETURN(1);
+ goto error;
succ_num++;
mi->unlock_slave_threads();
}
@@ -1196,14 +1201,14 @@ bool Master_info_index::init_all_master_info()
/* Master_info was not registered; add it */
if (master_info_index->add_master_info(mi, FALSE))
- DBUG_RETURN(1);
+ goto error;
succ_num++;
if (!opt_skip_slave_start)
{
if (start_slave_threads(current_thd,
1 /* need mutex */,
- 0 /* no wait for start*/,
+ 1 /* wait for start*/,
mi,
buf_master_info_file,
buf_relay_log_info_file,
@@ -1222,6 +1227,8 @@ bool Master_info_index::init_all_master_info()
mi->unlock_slave_threads();
}
}
+ thd->reset_globals();
+ delete thd;
if (!err_num) // No Error on read Master_info
{
@@ -1229,16 +1236,19 @@ bool Master_info_index::init_all_master_info()
sql_print_information("Reading of all Master_info entries succeded");
DBUG_RETURN(0);
}
- else if (succ_num) // Have some Error and some Success
+ if (succ_num) // Have some Error and some Success
{
sql_print_warning("Reading of some Master_info entries failed");
DBUG_RETURN(2);
}
- else // All failed
- {
- sql_print_error("Reading of all Master_info entries failed!");
- DBUG_RETURN(1);
- }
+
+ sql_print_error("Reading of all Master_info entries failed!");
+ DBUG_RETURN(1);
+
+error:
+ thd->reset_globals();
+ delete thd;
+ DBUG_RETURN(1);
}