Undoing 2 parts of changeset 1.1730.1.1 :
- the one about BUG#2921 - the one about relay log flushing Both will be rewritten in a next changeset (this one will not be pushed before the next changeset). sql/log.cc: undo sql/log_event.cc: undo sql/repl_failsafe.cc: undo sql/slave.cc: undo sql/slave.h: undo sql/sql_repl.cc: undo
This commit is contained in:
parent
b2147e2563
commit
843d6df523
@ -695,7 +695,7 @@ int MYSQL_LOG::purge_first_log(struct st_relay_log_info* rli)
|
|||||||
sizeof(rli->relay_log_name)-1);
|
sizeof(rli->relay_log_name)-1);
|
||||||
|
|
||||||
/* Store where we are in the new file for the execution thread */
|
/* Store where we are in the new file for the execution thread */
|
||||||
flush_relay_log_info(rli, 0);
|
flush_relay_log_info(rli);
|
||||||
|
|
||||||
err:
|
err:
|
||||||
pthread_mutex_unlock(&LOCK_index);
|
pthread_mutex_unlock(&LOCK_index);
|
||||||
|
@ -231,7 +231,7 @@ int Log_event::exec_event(struct st_relay_log_info* rli)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
rli->inc_pos(get_event_len(),log_pos);
|
rli->inc_pos(get_event_len(),log_pos);
|
||||||
flush_relay_log_info(rli, 1);
|
flush_relay_log_info(rli);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -2203,7 +2203,7 @@ int Stop_log_event::exec_event(struct st_relay_log_info* rli)
|
|||||||
the target position when in fact we have not.
|
the target position when in fact we have not.
|
||||||
*/
|
*/
|
||||||
rli->inc_pos(get_event_len(), 0);
|
rli->inc_pos(get_event_len(), 0);
|
||||||
flush_relay_log_info(rli, 0);
|
flush_relay_log_info(rli);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2250,7 +2250,7 @@ int Rotate_log_event::exec_event(struct st_relay_log_info* rli)
|
|||||||
}
|
}
|
||||||
pthread_mutex_unlock(&rli->data_lock);
|
pthread_mutex_unlock(&rli->data_lock);
|
||||||
pthread_cond_broadcast(&rli->data_cond);
|
pthread_cond_broadcast(&rli->data_cond);
|
||||||
flush_relay_log_info(rli, 0);
|
flush_relay_log_info(rli);
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -920,7 +920,7 @@ int load_master_data(THD* thd)
|
|||||||
active_mi->rli.master_log_pos = active_mi->master_log_pos;
|
active_mi->rli.master_log_pos = active_mi->master_log_pos;
|
||||||
strmake(active_mi->rli.master_log_name,active_mi->master_log_name,
|
strmake(active_mi->rli.master_log_name,active_mi->master_log_name,
|
||||||
sizeof(active_mi->rli.master_log_name)-1);
|
sizeof(active_mi->rli.master_log_name)-1);
|
||||||
flush_relay_log_info(&active_mi->rli, 0);
|
flush_relay_log_info(&active_mi->rli);
|
||||||
pthread_cond_broadcast(&active_mi->rli.data_cond);
|
pthread_cond_broadcast(&active_mi->rli.data_cond);
|
||||||
pthread_mutex_unlock(&active_mi->rli.data_lock);
|
pthread_mutex_unlock(&active_mi->rli.data_lock);
|
||||||
thd->proc_info = "starting slave";
|
thd->proc_info = "starting slave";
|
||||||
|
52
sql/slave.cc
52
sql/slave.cc
@ -584,26 +584,19 @@ int start_slave_threads(bool need_slave_mutex, bool wait_for_start,
|
|||||||
lock_cond_sql = &mi->rli.run_lock;
|
lock_cond_sql = &mi->rli.run_lock;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
if (thread_mask & SLAVE_IO)
|
||||||
We must first start the SQL thread, becasue for lock_slave_threads() to work
|
|
||||||
we must first unlock mi->rli.run_lock and then mi->run_lock
|
|
||||||
If we don't do this, we will get a deadlock if two threads calls START SLAVE
|
|
||||||
at the same time.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (thread_mask & SLAVE_SQL)
|
|
||||||
error=start_slave_thread(handle_slave_sql,lock_sql,lock_cond_sql,
|
|
||||||
cond_sql,
|
|
||||||
&mi->rli.slave_running, &mi->rli.slave_run_id,
|
|
||||||
mi);
|
|
||||||
if (!error && (thread_mask & SLAVE_IO))
|
|
||||||
{
|
|
||||||
error=start_slave_thread(handle_slave_io,lock_io,lock_cond_io,
|
error=start_slave_thread(handle_slave_io,lock_io,lock_cond_io,
|
||||||
cond_io,
|
cond_io,
|
||||||
&mi->slave_running, &mi->slave_run_id,
|
&mi->slave_running, &mi->slave_run_id,
|
||||||
mi);
|
mi);
|
||||||
|
if (!error && (thread_mask & SLAVE_SQL))
|
||||||
|
{
|
||||||
|
error=start_slave_thread(handle_slave_sql,lock_sql,lock_cond_sql,
|
||||||
|
cond_sql,
|
||||||
|
&mi->rli.slave_running, &mi->rli.slave_run_id,
|
||||||
|
mi);
|
||||||
if (error)
|
if (error)
|
||||||
terminate_slave_threads(mi, thread_mask & SLAVE_SQL, 0);
|
terminate_slave_threads(mi, thread_mask & SLAVE_IO, 0);
|
||||||
}
|
}
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
}
|
}
|
||||||
@ -1438,7 +1431,7 @@ Failed to open the existing relay log info file '%s' (errno %d)",
|
|||||||
before flush_relay_log_info
|
before flush_relay_log_info
|
||||||
*/
|
*/
|
||||||
reinit_io_cache(&rli->info_file, WRITE_CACHE,0L,0,1);
|
reinit_io_cache(&rli->info_file, WRITE_CACHE,0L,0,1);
|
||||||
if ((error= flush_relay_log_info(rli, 0)))
|
if ((error= flush_relay_log_info(rli)))
|
||||||
sql_print_error("Failed to flush relay log info file");
|
sql_print_error("Failed to flush relay log info file");
|
||||||
if (count_relay_log_space(rli))
|
if (count_relay_log_space(rli))
|
||||||
{
|
{
|
||||||
@ -2286,7 +2279,7 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli)
|
|||||||
rli->inc_pos(ev->get_event_len(),
|
rli->inc_pos(ev->get_event_len(),
|
||||||
type_code != STOP_EVENT ? ev->log_pos : LL(0),
|
type_code != STOP_EVENT ? ev->log_pos : LL(0),
|
||||||
1/* skip lock*/);
|
1/* skip lock*/);
|
||||||
flush_relay_log_info(rli, 0);
|
flush_relay_log_info(rli);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Protect against common user error of setting the counter to 1
|
Protect against common user error of setting the counter to 1
|
||||||
@ -3246,7 +3239,6 @@ static int safe_reconnect(THD* thd, MYSQL* mysql, MASTER_INFO* mi,
|
|||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
flush_relay_log_info()
|
flush_relay_log_info()
|
||||||
rli Relay log information
|
rli Relay log information
|
||||||
flush_cur_log Flush the current log if it's a hot log.
|
|
||||||
|
|
||||||
NOTES
|
NOTES
|
||||||
- As this is only called by the slave thread, we don't need to
|
- As this is only called by the slave thread, we don't need to
|
||||||
@ -3259,8 +3251,6 @@ static int safe_reconnect(THD* thd, MYSQL* mysql, MASTER_INFO* mi,
|
|||||||
If this would not be the case, we would have to ensure that we
|
If this would not be the case, we would have to ensure that we
|
||||||
don't delete the relay log file where the transaction started when
|
don't delete the relay log file where the transaction started when
|
||||||
we switch to a new relay log file.
|
we switch to a new relay log file.
|
||||||
- The reason for flushing current log is to ensure that we have saved on
|
|
||||||
disk the last query the SQL thread read
|
|
||||||
|
|
||||||
TODO
|
TODO
|
||||||
- Change the log file information to a binary format to avoid calling
|
- Change the log file information to a binary format to avoid calling
|
||||||
@ -3271,7 +3261,7 @@ static int safe_reconnect(THD* thd, MYSQL* mysql, MASTER_INFO* mi,
|
|||||||
1 write error
|
1 write error
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool flush_relay_log_info(RELAY_LOG_INFO* rli, bool flush_cur_log)
|
bool flush_relay_log_info(RELAY_LOG_INFO* rli)
|
||||||
{
|
{
|
||||||
bool error=0;
|
bool error=0;
|
||||||
IO_CACHE *file = &rli->info_file;
|
IO_CACHE *file = &rli->info_file;
|
||||||
@ -3294,23 +3284,7 @@ bool flush_relay_log_info(RELAY_LOG_INFO* rli, bool flush_cur_log)
|
|||||||
error=1;
|
error=1;
|
||||||
if (flush_io_cache(file))
|
if (flush_io_cache(file))
|
||||||
error=1;
|
error=1;
|
||||||
|
/* Flushing the relay log is done by the slave I/O thread */
|
||||||
/*
|
|
||||||
We want to flush the io log here if this is a hot cache to ensure
|
|
||||||
that we have the execute SQL statement on disk.
|
|
||||||
*/
|
|
||||||
if (flush_cur_log)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
The following mutex is to protect us against log changes in middle of
|
|
||||||
the flush_io_cache() call
|
|
||||||
*/
|
|
||||||
pthread_mutex_lock(&rli->mi->data_lock);
|
|
||||||
/* Only flush hot logs */
|
|
||||||
if (rli->cur_log != &rli->cache_buf && flush_io_cache(rli->cur_log))
|
|
||||||
error=1;
|
|
||||||
pthread_mutex_unlock(&rli->mi->data_lock);
|
|
||||||
}
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3531,7 +3505,7 @@ rli->relay_log_pos=%s rli->pending=%lu",
|
|||||||
rli->pending=0;
|
rli->pending=0;
|
||||||
strmake(rli->relay_log_name,rli->linfo.log_file_name,
|
strmake(rli->relay_log_name,rli->linfo.log_file_name,
|
||||||
sizeof(rli->relay_log_name)-1);
|
sizeof(rli->relay_log_name)-1);
|
||||||
flush_relay_log_info(rli, 0);
|
flush_relay_log_info(rli);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -362,7 +362,7 @@ typedef struct st_table_rule_ent
|
|||||||
int init_slave();
|
int init_slave();
|
||||||
void init_slave_skip_errors(const char* arg);
|
void init_slave_skip_errors(const char* arg);
|
||||||
bool flush_master_info(MASTER_INFO* mi);
|
bool flush_master_info(MASTER_INFO* mi);
|
||||||
bool flush_relay_log_info(RELAY_LOG_INFO* rli, bool flush_cur_log);
|
bool flush_relay_log_info(RELAY_LOG_INFO* rli);
|
||||||
int register_slave_on_master(MYSQL* mysql);
|
int register_slave_on_master(MYSQL* mysql);
|
||||||
int terminate_slave_threads(MASTER_INFO* mi, int thread_mask,
|
int terminate_slave_threads(MASTER_INFO* mi, int thread_mask,
|
||||||
bool skip_lock = 0);
|
bool skip_lock = 0);
|
||||||
|
@ -1015,10 +1015,10 @@ int change_master(THD* thd, MASTER_INFO* mi)
|
|||||||
If we don't write new coordinates to disk now, then old will remain in
|
If we don't write new coordinates to disk now, then old will remain in
|
||||||
relay-log.info until START SLAVE is issued; but if mysqld is shutdown
|
relay-log.info until START SLAVE is issued; but if mysqld is shutdown
|
||||||
before START SLAVE, then old will remain in relay-log.info, and will be the
|
before START SLAVE, then old will remain in relay-log.info, and will be the
|
||||||
in-memory value at restart (thus causing errors, as the old relay log
|
in-memory value at restart (thus causing errors, as the old relay log does
|
||||||
does not exist anymore).
|
not exist anymore).
|
||||||
*/
|
*/
|
||||||
flush_relay_log_info(&mi->rli, 0);
|
flush_relay_log_info(&mi->rli);
|
||||||
pthread_cond_broadcast(&mi->data_cond);
|
pthread_cond_broadcast(&mi->data_cond);
|
||||||
pthread_mutex_unlock(&mi->rli.data_lock);
|
pthread_mutex_unlock(&mi->rli.data_lock);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user