summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <guilhem@mysql.com>2004-03-10 16:30:47 +0100
committerunknown <guilhem@mysql.com>2004-03-10 16:30:47 +0100
commit843d6df523a255e9ecb864d0ed26761e353f4639 (patch)
treedb053b8bdf0f145409d1e621ed5a98cdff683a9f
parentb2147e25639c20494820f5ca409e6efb8dd7e497 (diff)
downloadmariadb-git-843d6df523a255e9ecb864d0ed26761e353f4639.tar.gz
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
-rw-r--r--sql/log.cc2
-rw-r--r--sql/log_event.cc6
-rw-r--r--sql/repl_failsafe.cc2
-rw-r--r--sql/slave.cc52
-rw-r--r--sql/slave.h2
-rw-r--r--sql/sql_repl.cc6
6 files changed, 22 insertions, 48 deletions
diff --git a/sql/log.cc b/sql/log.cc
index 7b402421951..559d30f28ba 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -695,7 +695,7 @@ int MYSQL_LOG::purge_first_log(struct st_relay_log_info* rli)
sizeof(rli->relay_log_name)-1);
/* Store where we are in the new file for the execution thread */
- flush_relay_log_info(rli, 0);
+ flush_relay_log_info(rli);
err:
pthread_mutex_unlock(&LOCK_index);
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 4e2aac8093b..d2957165e77 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -231,7 +231,7 @@ int Log_event::exec_event(struct st_relay_log_info* rli)
else
{
rli->inc_pos(get_event_len(),log_pos);
- flush_relay_log_info(rli, 1);
+ flush_relay_log_info(rli);
}
}
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.
*/
rli->inc_pos(get_event_len(), 0);
- flush_relay_log_info(rli, 0);
+ flush_relay_log_info(rli);
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_cond_broadcast(&rli->data_cond);
- flush_relay_log_info(rli, 0);
+ flush_relay_log_info(rli);
DBUG_RETURN(0);
}
diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc
index 61d4cee4c09..6599516044a 100644
--- a/sql/repl_failsafe.cc
+++ b/sql/repl_failsafe.cc
@@ -920,7 +920,7 @@ int load_master_data(THD* thd)
active_mi->rli.master_log_pos = active_mi->master_log_pos;
strmake(active_mi->rli.master_log_name,active_mi->master_log_name,
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_mutex_unlock(&active_mi->rli.data_lock);
thd->proc_info = "starting slave";
diff --git a/sql/slave.cc b/sql/slave.cc
index 21337e0476e..b497880aaa3 100644
--- a/sql/slave.cc
+++ b/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;
}
- /*
- 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))
- {
+ if (thread_mask & SLAVE_IO)
error=start_slave_thread(handle_slave_io,lock_io,lock_cond_io,
cond_io,
&mi->slave_running, &mi->slave_run_id,
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)
- terminate_slave_threads(mi, thread_mask & SLAVE_SQL, 0);
+ terminate_slave_threads(mi, thread_mask & SLAVE_IO, 0);
}
DBUG_RETURN(error);
}
@@ -1438,7 +1431,7 @@ Failed to open the existing relay log info file '%s' (errno %d)",
before flush_relay_log_info
*/
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");
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(),
type_code != STOP_EVENT ? ev->log_pos : LL(0),
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
@@ -3246,7 +3239,6 @@ static int safe_reconnect(THD* thd, MYSQL* mysql, MASTER_INFO* mi,
SYNOPSIS
flush_relay_log_info()
rli Relay log information
- flush_cur_log Flush the current log if it's a hot log.
NOTES
- 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
don't delete the relay log file where the transaction started when
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
- 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
*/
-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;
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;
if (flush_io_cache(file))
error=1;
-
- /*
- 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);
- }
+ /* Flushing the relay log is done by the slave I/O thread */
return error;
}
@@ -3531,7 +3505,7 @@ rli->relay_log_pos=%s rli->pending=%lu",
rli->pending=0;
strmake(rli->relay_log_name,rli->linfo.log_file_name,
sizeof(rli->relay_log_name)-1);
- flush_relay_log_info(rli, 0);
+ flush_relay_log_info(rli);
}
/*
diff --git a/sql/slave.h b/sql/slave.h
index 0ae0c7d6de4..8331e722a51 100644
--- a/sql/slave.h
+++ b/sql/slave.h
@@ -362,7 +362,7 @@ typedef struct st_table_rule_ent
int init_slave();
void init_slave_skip_errors(const char* arg);
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 terminate_slave_threads(MASTER_INFO* mi, int thread_mask,
bool skip_lock = 0);
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 85dcd3b5236..7c56670935b 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -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
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
- in-memory value at restart (thus causing errors, as the old relay log
- does not exist anymore).
+ in-memory value at restart (thus causing errors, as the old relay log does
+ not exist anymore).
*/
- flush_relay_log_info(&mi->rli, 0);
+ flush_relay_log_info(&mi->rli);
pthread_cond_broadcast(&mi->data_cond);
pthread_mutex_unlock(&mi->rli.data_lock);