include/master-slave.inc
Warnings:
Note	####	Sending passwords in plain text without SSL/TLS is extremely insecure.
Note	####	Storing MySQL user name or password information in the master info repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START SLAVE; see the 'START SLAVE Syntax' in the MySQL Manual for more information.
[connection master]
include/stop_slave.inc
RESET MASTER;
include/start_slave.inc
call mtr.add_suppression("Attempting backtrace");
call mtr.add_suppression("allocated tablespace *., old maximum was 0");
call mtr.add_suppression("Error in Log_event::read_log_event()");
call mtr.add_suppression("Buffered warning: Performance schema disabled");
CREATE TABLE t1(a LONGBLOB) ENGINE=INNODB;
# Test case1: Set DEBUG POINT before binlog to make
#             the master crash for transaction
# Lets stop the slave IO thread first, so that it does not timeout on
# reconnection while the master is down (it happened before on some
# slow hosts).
include/sync_slave_sql_with_master.inc
include/stop_slave_io.inc
BEGIN;
INSERT INTO t1 (a) VALUES (REPEAT('a',2));
INSERT INTO t1 (a) VALUES (REPEAT('a',2));
INSERT INTO t1 (a) VALUES (REPEAT('a',2));
COMMIT;
ERROR HY000: Lost connection to MySQL server during query
# Restart the master server
# Test the transaction statements will not be binlogged
include/show_binlog_events.inc
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000001	#	Query	#	#	use `test`; CREATE TABLE t1(a LONGBLOB) ENGINE=INNODB
include/assert.inc [On master, test the data will be rolled back after restart.]
# lets restart the slave io thread and check that
# the slave gets synchronized again
include/start_slave_io.inc
include/sync_slave_sql_with_master.inc
# On slave, test replication will work fine, and the data 
#           is not replicated
include/diff_tables.inc [master:test.t1, slave:test.t1]
# Test case2: Set DEBUG POINT after binlog, and before the date
#             is committed to make crash for transaction
# Lets stop the slave IO thread first, so that it does not timeout on
# reconnection while the master is down (it happened before on some
# slow hosts).
include/sync_slave_sql_with_master.inc
include/stop_slave_io.inc
BEGIN;
INSERT INTO t1 (a) VALUES (REPEAT('a',2));
INSERT INTO t1 (a) VALUES (REPEAT('a',2));
INSERT INTO t1 (a) VALUES (REPEAT('a',2));
COMMIT;
ERROR HY000: Lost connection to MySQL server during query
# Restart the master server
# Test the transaction statements will be binlogged
include/show_binlog_events.inc
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000002	#	Query	#	#	BEGIN
master-bin.000002	#	Table_map	#	#	table_id: # (test.t1)
master-bin.000002	#	Write_rows	#	#	table_id: # flags: STMT_END_F
master-bin.000002	#	Table_map	#	#	table_id: # (test.t1)
master-bin.000002	#	Write_rows	#	#	table_id: # flags: STMT_END_F
master-bin.000002	#	Table_map	#	#	table_id: # (test.t1)
master-bin.000002	#	Write_rows	#	#	table_id: # flags: STMT_END_F
master-bin.000002	#	Xid	#	#	COMMIT /* XID */
include/assert.inc [On master, test the data will be recovered after the master restart.]
# lets restart the slave io thread and check that
# the slave gets synchronized again
include/start_slave_io.inc
include/sync_slave_sql_with_master.inc
# On slave, test replication will work fine, and the data is replicated
include/diff_tables.inc [master:test.t1, slave:test.t1]
DROP TABLE t1;
include/sync_slave_sql_with_master.inc
include/stop_slave.inc
CREATE TABLE t1(a LONGBLOB) ENGINE=INNODB;
# Test case3: Set DEBUG POINT in the middle of binlog to
#             make the master crash for transaction.
BEGIN;
INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
INSERT INTO t1 (a) VALUES (REPEAT('a',6144));
COMMIT;
ERROR HY000: Lost connection to MySQL server during query
# Restart the master server
# Test the halfly binlogged transaction will be trimmed
# from the crashed binlog file
include/show_binlog_events.inc
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000003	#	Query	#	#	use `test`; CREATE TABLE t1(a LONGBLOB) ENGINE=INNODB
# Test the data will not be recovered successfully
# after the master restart.
SELECT COUNT(*) FROM t1;
COUNT(*)
0
# Test case4: Set DEBUG POINT in the middle of binlog to
#             make the master crash for non-transaction.
CREATE TABLE t2(a LONGBLOB) ENGINE=MYISAM;
INSERT INTO t2 (a) VALUES (REPEAT('a',16384));
ERROR HY000: Lost connection to MySQL server during query
# Restart the master server
# Test the halfly binlogged non-transaction statement will be trimmed
# from the crashed binlog file
include/show_binlog_events.inc
Log_name	Pos	Event_type	Server_id	End_log_pos	Info
master-bin.000004	#	Query	#	#	use `test`; CREATE TABLE t2(a LONGBLOB) ENGINE=MYISAM
# Test the data will not be recovered successfully
# after the master restart.
SELECT COUNT(*) FROM t2;
COUNT(*)
0
DROP TABLE t1, t2;
CHANGE MASTER TO MASTER_AUTO_POSITION= 0;
