diff options
Diffstat (limited to 'sql/repl_failsafe.cc')
-rw-r--r-- | sql/repl_failsafe.cc | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index d125c95e839..f254ffb3df3 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -736,6 +736,7 @@ static int fetch_db_tables(THD *thd, MYSQL *mysql, const char *db, table.db= (char*) db; table.real_name= (char*) table_name; table.updating= 1; + if (!tables_ok(thd, &table)) continue; } @@ -768,7 +769,7 @@ int load_master_data(THD* thd) We do not want anyone messing with the slave at all for the entire duration of the data load. */ - LOCK_ACTIVE_MI; + pthread_mutex_lock(&LOCK_active_mi); lock_slave_threads(active_mi); init_thread_mask(&restart_thread_mask,active_mi,0 /*not inverse*/); if (restart_thread_mask && @@ -777,7 +778,7 @@ int load_master_data(THD* thd) { send_error(thd,error); unlock_slave_threads(active_mi); - UNLOCK_ACTIVE_MI; + pthread_mutex_unlock(&LOCK_active_mi); return 1; } @@ -895,7 +896,7 @@ int load_master_data(THD* thd) cleanup_mysql_results(db_res, cur_table_res - 1, table_res); - // adjust position in the master + // adjust replication coordinates from the master if (master_status_res) { MYSQL_ROW row = mysql_fetch_row(master_status_res); @@ -908,10 +909,19 @@ int load_master_data(THD* thd) */ if (row && row[0] && row[1]) { + /* + If the slave's master info is not inited, we init it, then we write + the new coordinates to it. Must call init_master_info() *before* + setting active_mi, because init_master_info() sets active_mi with + defaults. + */ + if (init_master_info(active_mi, master_info_file, relay_log_info_file, + 0)) + send_error(thd, ER_MASTER_INFO); strmake(active_mi->master_log_name, row[0], sizeof(active_mi->master_log_name)); active_mi->master_log_pos = strtoull(row[1], (char**) 0, 10); - // don't hit the magic number + /* at least in recent versions, the condition below should be false */ if (active_mi->master_log_pos < BIN_LOG_HEADER_SIZE) active_mi->master_log_pos = BIN_LOG_HEADER_SIZE; /* @@ -938,7 +948,7 @@ int load_master_data(THD* thd) { send_error(thd, 0, "Failed purging old relay logs"); unlock_slave_threads(active_mi); - UNLOCK_ACTIVE_MI; + pthread_mutex_unlock(&LOCK_active_mi); return 1; } pthread_mutex_lock(&active_mi->rli.data_lock); @@ -969,7 +979,7 @@ int load_master_data(THD* thd) err: unlock_slave_threads(active_mi); - UNLOCK_ACTIVE_MI; + pthread_mutex_unlock(&LOCK_active_mi); thd->proc_info = 0; mysql_close(&mysql); // safe to call since we always do mysql_init() |