Debian Codegraph @

mysql-test/suite/binlog/t/start_alter_mysqlbinlog_replay.test

raw
1 #
2 # MENT-662: Lag Free Alter On Slave
3 #
4
5 --echo #
6 --echo # Test verifies replay of binary logs which contain
7 --echo # SA/RA/CA works fine.
8 --echo # Generate a binary log with alter events and use mysqlbinlog tool to
9 --echo # generate a sql file for replay. Source it on an clean master and
10 --echo # verify the correctness. Use the latest binlog and repeat the same
11 --echo # process mentioned above and observe replay works fine.
12 --echo #
13 --source include/have_log_bin.inc
14 --source include/have_innodb.inc
15 --source include/have_binlog_format_statement.inc
16
17 --let $binlog_alter_two_phase= `select @@binlog_alter_two_phase`
18 set global binlog_alter_two_phase = ON;
19 set binlog_alter_two_phase = ON;
20
21 create table t1 (f1 int primary key) engine=InnoDB;
22 create table t2 (f1 int primary key, constraint c1 foreign key (f1) references t1(f1)) engine=innodb;
23
24 --error ER_CANT_CREATE_TABLE
25 alter table t2 add constraint c1 foreign key (f1) references t1(f1);
26
27 drop table t2, t1;
28 select @@gtid_binlog_state;
29 FLUSH LOGS;
30
31 let MYSQLD_DATADIR= `select @@datadir;`;
32 --exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/slave_1.sql
33
34 --echo # reset the binlog
35 RESET MASTER;
36 --echo # execute the binlog
37 --exec $MYSQL --port=$MASTER_MYPORT --host=127.0.0.1 -e "source $MYSQLTEST_VARDIR/tmp/slave_1.sql"
38 SELECT @@gtid_binlog_state;
39 FLUSH LOGS;
40 --echo # Replay 1: One more time to simulate S->S case
41 --exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/slave_2.sql
42
43 RESET MASTER;
44 --echo # execute the binlog
45 --exec $MYSQL --port=$MASTER_MYPORT --host=127.0.0.1 -e "source $MYSQLTEST_VARDIR/tmp/slave_2.sql"
46 SELECT @@gtid_binlog_state;
47 FLUSH LOGS;
48 --echo # Replay 2: One more time to simulate S->S case
49 --exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/slave_3.sql
50 RESET MASTER;
51 --echo # execute the binlog
52 --exec $MYSQL --port=$MASTER_MYPORT --host=127.0.0.1 -e "source $MYSQLTEST_VARDIR/tmp/slave_3.sql"
53 SELECT @@gtid_binlog_state;
54
55 --echo # clean up
56 remove_file $MYSQLTEST_VARDIR/tmp/slave_1.sql;
57 remove_file $MYSQLTEST_VARDIR/tmp/slave_2.sql;
58 remove_file $MYSQLTEST_VARDIR/tmp/slave_3.sql;
59 RESET MASTER;
60
61 --eval set global binlog_alter_two_phase=$binlog_alter_two_phase