summaryrefslogtreecommitdiff
path: root/mysql-test/include/setup_fake_relay_log.inc
diff options
context:
space:
mode:
authorSven Sandberg <sven@mysql.com>2008-12-29 17:04:10 +0100
committerSven Sandberg <sven@mysql.com>2008-12-29 17:04:10 +0100
commitba835f89ba4a07344322765c27c424a2ea96f6ee (patch)
tree140102f9249f7ff4d6beb0772df2511a8ec0abc8 /mysql-test/include/setup_fake_relay_log.inc
parent47c0ec508467b4941e6e388e33dc688b7247befb (diff)
downloadmariadb-git-ba835f89ba4a07344322765c27c424a2ea96f6ee.tar.gz
BUG#40482: server/mysqlbinlog crashes when reading invalid Incident_log_event
Problem: When an Incident_log_event contains a bad incident number on disk, the server crashes with an assertion. Fix: Don't validate input with assertions. Use errors. mysql-test/include/cleanup_fake_relay_log.inc: Added auxiliary file to restore things that setup_fake_relay_log.inc did. mysql-test/include/setup_fake_relay_log.inc: Added auxiliary file to setup replication from an existing relay log. mysql-test/std_data/bug40482-bin.000001: Binlog file for rpl.rpl_binlog_corruption mysql-test/suite/rpl/t/rpl_binlog_corruption.test: New test file. sql/log_event.cc: Check that the incident number is correct at the time the event is constructed. Do not assert it at the time it is printed. sql/log_event.h: Incident_log_event::is_valid() should verify that the incident number is valid. sql/rpl_constants.h: Incident numbers should be hard-coded, since they may appear in files.
Diffstat (limited to 'mysql-test/include/setup_fake_relay_log.inc')
-rw-r--r--mysql-test/include/setup_fake_relay_log.inc78
1 files changed, 78 insertions, 0 deletions
diff --git a/mysql-test/include/setup_fake_relay_log.inc b/mysql-test/include/setup_fake_relay_log.inc
new file mode 100644
index 00000000000..8113ed6dc10
--- /dev/null
+++ b/mysql-test/include/setup_fake_relay_log.inc
@@ -0,0 +1,78 @@
+# ==== Purpose ====
+#
+# Setup replication from an existing relay log in the current
+# connection.
+#
+# ==== Usage ====
+#
+# Make sure the slave is not running and issue:
+#
+# let $fake_relay_log= /path/to/fake-relay-log-file.000001
+# source include/setup_fake_relay_log.inc;
+# START SLAVE SQL_THREAD; # setup_fake_relay_log doesn't start slave
+# ...
+# source include/cleanup_fake_relay_log.inc
+#
+# You must run the server with --relay-log=FILE. You probably want to
+# run with --replicate-same-server-id too.
+#
+# ==== Implementation ====
+#
+# First makes a sanity check, ensuring that the slave threads are not
+# running. Then copies the $fake_relay_log to RELAY_BIN-fake.000001,
+# where RELAY_BIN is the basename of the relay log, and updates
+# RELAY_BIN.index. Finally issues CHANGE MASTER so that it uses the
+# given files.
+#
+# ==== Side effects ====
+#
+# Creates a binlog file and a binlog index file, and sets
+# @@global.relay_log_purge=1. All this is restored when you call
+# cleanup_fake_relay_log.inc.
+#
+# Enables the query log.
+
+
+--disable_query_log
+
+# Print message.
+let $_fake_relay_log_printable= `SELECT REPLACE('$fake_relay_log', '$MYSQL_TEST_DIR', 'MYSQL_TEST_DIR')`;
+--echo Setting up fake replication from $_fake_relay_log_printable
+
+# Sanity check.
+let $_sql_running= query_get_value(SHOW SLAVE STATUS, Slave_SQL_Running, 1);
+let $_io_running= query_get_value(SHOW SLAVE STATUS, Slave_IO_Running, 1);
+if (`SELECT "$_sql_running" = "Yes" OR "$_io_running" = "Yes"`) {
+ --echo Error: Slave was running when test case sourced
+ --echo include/setup_fake_replication.inc
+ --echo Slave_IO_Running = $_io_running; Slave_SQL_Running = $_sql_running
+ --echo Printing some debug info:
+ SHOW SLAVE STATUS;
+ SHOW MASTER STATUS;
+ SHOW BINLOG EVENTS;
+ SHOW PROCESSLIST;
+}
+
+# Read server variables.
+let $MYSQLD_DATADIR= `SELECT @@datadir`;
+let $_fake_filename= query_get_value(SHOW VARIABLES LIKE 'relay_log', Value, 1);
+if (`SELECT '$_fake_filename' = ''`) {
+ --echo Badly written test case: relay_log variable is empty. Please use the
+ --echo server option --relay-log=FILE.
+}
+let $_fake_relay_log= $MYSQLD_DATADIR/$_fake_filename-fake.000001;
+let $_fake_relay_index= $MYSQLD_DATADIR/$_fake_filename.index;
+# Need to restore relay_log_purge in cleanup_fake_relay_log.inc, since
+# CHANGE MASTER modifies it (see the manual for CHANGE MASTER).
+let $_fake_relay_log_purge= `SELECT @@global.relay_log_purge`;
+
+# Create relay log file.
+copy_file $fake_relay_log $_fake_relay_log;
+
+# Create relay log index.
+eval SELECT '$_fake_relay_log' INTO OUTFILE '$_fake_relay_index';
+
+# Setup replication from existing relay log.
+eval CHANGE MASTER TO MASTER_HOST='dummy.localdomain', RELAY_LOG_FILE='$_fake_relay_log', RELAY_LOG_POS=4;
+
+--enable_query_log