summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <guilhem@mysql.com>2003-11-28 16:22:45 +0100
committerunknown <guilhem@mysql.com>2003-11-28 16:22:45 +0100
commit57eda3053fd36ee9554ca328014f5d1eaddb6726 (patch)
tree63085006ffd451ccb36725fdcc14fb5b7fc3e285 /sql
parenta55db6213e469c051690570c6ac244d39d13967d (diff)
parent7ec796f31afd8b6d09002c0eb06d0f3a96f4d612 (diff)
downloadmariadb-git-57eda3053fd36ee9554ca328014f5d1eaddb6726.tar.gz
Merge gbichot@213.136.52.20:/home/bk/mysql-4.1
into mysql.com:/home/mysql_src/mysql-4.1
Diffstat (limited to 'sql')
-rw-r--r--sql/slave.cc38
1 files changed, 24 insertions, 14 deletions
diff --git a/sql/slave.cc b/sql/slave.cc
index 5fab217762c..5ace523be73 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -2085,6 +2085,30 @@ bool flush_master_info(MASTER_INFO* mi, bool flush_relay_log_cache)
DBUG_PRINT("enter",("master_pos: %ld", (long) mi->master_log_pos));
/*
+ Flush the relay log to disk. If we don't do it, then the relay log while
+ have some part (its last kilobytes) in memory only, so if the slave server
+ dies now, with, say, from master's position 100 to 150 in memory only (not
+ on disk), and with position 150 in master.info, then when the slave
+ restarts, the I/O thread will fetch binlogs from 150, so in the relay log
+ we will have "[0, 100] U [150, infinity[" and nobody will notice it, so the
+ SQL thread will jump from 100 to 150, and replication will silently break.
+
+ When we come to this place in code, relay log may or not be initialized;
+ the caller is responsible for setting 'flush_relay_log_cache' accordingly.
+ */
+ if (flush_relay_log_cache)
+ flush_io_cache(mi->rli.relay_log.get_log_file());
+
+ /*
+ We flushed the relay log BEFORE the master.info file, because if we crash
+ now, we will get a duplicate event in the relay log at restart. If we
+ flushed in the other order, we would get a hole in the relay log.
+ And duplicate is better than hole (with a duplicate, in later versions we
+ can add detection and scrap one event; with a hole there's nothing we can
+ do).
+ */
+
+ /*
In certain cases this code may create master.info files that seems
corrupted, because of extra lines filled with garbage in the end
file (this happens if new contents take less space than previous
@@ -2101,20 +2125,6 @@ bool flush_master_info(MASTER_INFO* mi, bool flush_relay_log_cache)
(int)(mi->ssl), mi->ssl_ca, mi->ssl_capath, mi->ssl_cert,
mi->ssl_cipher, mi->ssl_key);
flush_io_cache(file);
- /*
- Flush the relay log to disk. If we don't do it, then the relay log while
- have some part (its last kilobytes) in memory only, so if the slave server
- dies now, with, say, from master's position 100 to 150 in memory only (not
- on disk), and with position 150 in master.info, then when the slave
- restarts, the I/O thread will fetch binlogs from 150, so in the relay log
- we will have "[0, 100] U [150, infinity[" and nobody will notice it, so the
- SQL thread will jump from 100 to 150, and replication will silently break.
-
- When we come to this place in code, relay log may or not be initialized;
- the caller is responsible for setting 'flush_relay_log_cache' accordingly.
- */
- if (flush_relay_log_cache)
- flush_io_cache(mi->rli.relay_log.get_log_file());
DBUG_RETURN(0);
}