summaryrefslogtreecommitdiff
path: root/sql/log_event.h
diff options
context:
space:
mode:
authorunknown <serg@serg.mylan>2005-02-09 20:04:28 +0100
committerunknown <serg@serg.mylan>2005-02-09 20:04:28 +0100
commit9297872d75f4754df8bbf607e380fc6cf68251f1 (patch)
treee67ca6abbf7a9ea5ce41fb7435ffae76dbde21c8 /sql/log_event.h
parentbe255d6577e5f20ba4bb72b44e7da8169b72197b (diff)
downloadmariadb-git-9297872d75f4754df8bbf607e380fc6cf68251f1.tar.gz
auto-ROLLBACK if binlog was not closed properly
auto-commit on Xid_log_event client/mysqlbinlog.cc: auto-ROLLBACK if binlog was not closed properly. mysql-test/r/ctype_ucs.result: results updated mysql-test/r/mix_innodb_myisam_binlog.result: results updated mysql-test/r/mysqlbinlog2.result: results updated mysql-test/r/rpl_relayrotate.result: results updated mysql-test/r/user_var.result: results updated mysql-test/t/ctype_ucs.test: finalize binlog before calling mysqlbinlog mysql-test/t/user_var.test: finalize binlog before calling mysqlbinlog sql/log_event.cc: commit at Xid_log_event comments edited sql/mysqld.cc: free(0) fixed sql/slave.cc: rollback at fake Rotate_log_event sql/sql_class.h: no commit_or_rollback argument for binlog->write(THD *thd, IO_CACHE *cache) sql/log.cc: don't write "COMMIT" query, Xid_log_event is enough sql/log_event.h: more comments for LOG_EVENT_BINLOG_IN_USE_F LOG_EVENT_FORCE_ROLLBACK_F added sql/sql_repl.cc: rollback at Rotate_log_event. don't consider binlog corrupted if it was open when we read Formar_description but closed when we got to the end sql/sql_repl.h: style fix
Diffstat (limited to 'sql/log_event.h')
-rw-r--r--sql/log_event.h73
1 files changed, 49 insertions, 24 deletions
diff --git a/sql/log_event.h b/sql/log_event.h
index bc950441ab0..3e9f89bef39 100644
--- a/sql/log_event.h
+++ b/sql/log_event.h
@@ -303,15 +303,38 @@ struct sql_ex_info
#endif
/*
- This flag only makes sense for Format_description_log_event.
- It is set not when the event is written, but when a binlog file
- is closed. It serves as a reliable indicator that binlog was
- closed correctly. (Stop_log_event is not enough, there's always
- a small chance that mysqld crashes in the middle of insert
- and end of the binlog would look like a Stop_log_event)
+ This flag only makes sense for Format_description_log_event. It is set
+ when the event is written, and *reset* when a binlog file is
+ closed (yes, it's the only case when MySQL modifies already written
+ part of binlog). Thus it is a reliable indicator that binlog was
+ closed correctly. (Stop_log_event is not enough, there's always a
+ small chance that mysqld crashes in the middle of insert and end of
+ the binlog would look like a Stop_log_event).
+
+ This flag is used to detect a restart after a crash,
+ and to provide "unbreakable" binlog. The problem is that on a crash
+ storage engines rollback automatically, while binlog does not.
+ To solve this we use this flag and automatically append ROLLBACK
+ to every non-closed binlog (append virtually, on reading, file itself
+ is not changed). If this flag is found, mysqlbinlog simply prints "ROLLBACK"
+ Replication master does not abort on binlog corruption, but takes it as EOF,
+ and replication slave forces a rollback in this case (see below).
+
+ Note, that old binlogs does not have this flag set, so we get a
+ a backward-compatible behaviour.
*/
-#define LOG_EVENT_BINLOG_CLOSED_F 0x1
+#define LOG_EVENT_BINLOG_IN_USE_F 0x1
+
+/*
+ This flag is only used for fake Rotate_log_event. When a master, doing
+ binlog dump, reaches the end of the binlog and fakes a rotate to make
+ the slave to go to a new file, this flag is used if there was no
+ "natural" Rotate_log_event.
+ If this flag is set, slave will execute ROLLBACK before going further
+*/
+
+#define LOG_EVENT_FORCE_ROLLBACK_F 0x1
/*
If the query depends on the thread (for example: TEMPORARY TABLE).
@@ -335,21 +358,22 @@ struct sql_ex_info
#define LOG_EVENT_SUPPRESS_USE_F 0x8
/*
- OPTIONS_WRITTEN_TO_BIN_LOG are the bits of thd->options which must be written
- to the binlog. OPTIONS_WRITTEN_TO_BINLOG could be written into the
- Format_description_log_event, so that if later we don't want to replicate a
- variable we did replicate, or the contrary, it's doable. But it should not be
- too hard to decide once for all of what we replicate and what we don't, among
- the fixed 32 bits of thd->options.
+ OPTIONS_WRITTEN_TO_BIN_LOG are the bits of thd->options which must be
+ written to the binlog. OPTIONS_WRITTEN_TO_BINLOG could be written
+ into the Format_description_log_event, so that if later we don't want
+ to replicate a variable we did replicate, or the contrary, it's
+ doable. But it should not be too hard to decide once for all of what
+ we replicate and what we don't, among the fixed 32 bits of
+ thd->options.
I (Guilhem) have read through every option's usage, and it looks like
- OPTION_AUTO_IS_NULL and OPTION_NO_FOREIGN_KEYS are the only ones which alter
- how the query modifies the table. It's good to replicate
- OPTION_RELAXED_UNIQUE_CHECKS too because otherwise, the slave may insert data
- slower than the master, in InnoDB.
+ OPTION_AUTO_IS_NULL and OPTION_NO_FOREIGN_KEYS are the only ones
+ which alter how the query modifies the table. It's good to replicate
+ OPTION_RELAXED_UNIQUE_CHECKS too because otherwise, the slave may
+ insert data slower than the master, in InnoDB.
OPTION_BIG_SELECTS is not needed (the slave thread runs with
- max_join_size=HA_POS_ERROR) and OPTION_BIG_TABLES is not needed either, as
- the manual says (because a too big in-memory temp table is automatically
- written to disk).
+ max_join_size=HA_POS_ERROR) and OPTION_BIG_TABLES is not needed
+ either, as the manual says (because a too big in-memory temp table is
+ automatically written to disk).
*/
#define OPTIONS_WRITTEN_TO_BIN_LOG (OPTION_AUTO_IS_NULL | \
OPTION_NO_FOREIGN_KEY_CHECKS | OPTION_RELAXED_UNIQUE_CHECKS)
@@ -470,14 +494,15 @@ public:
ulong data_written;
/*
- The master's server id (is preserved in the relay log; used to prevent from
- infinite loops in circular replication).
+ The master's server id (is preserved in the relay log; used to
+ prevent from infinite loops in circular replication).
*/
uint32 server_id;
/*
- Some 16 flags. Look above for LOG_EVENT_TIME_F, LOG_EVENT_FORCED_ROTATE_F,
- LOG_EVENT_THREAD_SPECIFIC_F, and LOG_EVENT_SUPPRESS_USE_F for notes.
+ Some 16 flags. Look above for LOG_EVENT_TIME_F,
+ LOG_EVENT_FORCED_ROTATE_F, LOG_EVENT_THREAD_SPECIFIC_F, and
+ LOG_EVENT_SUPPRESS_USE_F for notes.
*/
uint16 flags;