Debian Codegraph @

mysql-test/suite/ndb_rpl/t/ndb_rpl_slave_restart.test

raw
1 --source include/have_multi_ndb.inc
2 --source include/have_binlog_format_mixed_or_row.inc
3 --source suite/ndb_rpl/ndb_master-slave.inc
4
5 # note: server2 is another "master" connected to the master cluster
6
7 #
8 # Currently test only works with ndb since it retrieves "old"
9 # binlog positions with mysql.ndb_binlog_index and ndb_apply_status;
10 #
11
12 # create a table with one row, and make sure the other "master" gets it
13 CREATE TABLE t1 (c1 CHAR(15), c2 CHAR(15), c3 INT, PRIMARY KEY (c3)) ENGINE = NDB ;
14 # a dummy table such that we can make sure data gets into binlog on server2
15 CREATE TABLE t2 (a int key) ENGINE = NDB ;
16 connection server2;
17 reset master;
18 SHOW TABLES;
19 connection master;
20 INSERT INTO t1 VALUES ("row1","will go away",1);
21 SELECT * FROM t1 ORDER BY c3;
22 connection server2;
23 SELECT * FROM t1 ORDER BY c3;
24
25 # sync slave and retrieve epoch and stop the slave
26 connection master;
27 sync_slave_with_master;
28 SELECT MAX(epoch) FROM mysql.ndb_apply_status into @the_epoch;
29 --replace_column 1 <the_epoch>
30 SELECT @the_epoch;
31 let $the_epoch= `select @the_epoch` ;
32 SELECT * FROM t1 ORDER BY c3;
33 stop slave;
34
35 # Ignore the warning generated by ndbcluster's binlog thread
36 # when mysqld is restarted
37 --disable_query_log ONCE
38 call mtr.add_suppression("mysqld startup An incident event has been written");
39
40 # restart the slave server
41 let $mysqld_name=mysqld.1.slave;
42 let $allow_rpl_inited=1;
43 --source include/restart_mysqld.inc
44
45 # get the master binlog pos from the epoch, from the _other_ "master", server2
46 connection server2;
47 # insert some data to t1 which should not come into the binlog
48 # just so that we can do "show binlog events" to make sure the t1
49 # update is actually in the server2 binlog
50 set SQL_LOG_BIN=0;
51 insert into t2 values (1);
52 -- source include/show_binlog_events.inc
53 set SQL_LOG_BIN=1;
54 --replace_result $the_epoch <the_epoch>
55 --disable_query_log
56 --disable_result_log
57 eval SELECT @the_pos:=Position,
58 @the_file:=SUBSTRING_INDEX(REPLACE(FILE,'\\\\','/'), '/', -1)
59 FROM mysql.ndb_binlog_index WHERE epoch = $the_epoch ;
60 let $the_pos= `SELECT @the_pos` ;
61 let $the_file= `SELECT @the_file` ;
62
63 # now connect the slave to the _other_ "master"
64 connection slave;
65 --replace_result $MASTER_MYPORT1 <MASTER_PORT1>
66 eval CHANGE REPLICATION SOURCE TO
67 SOURCE_PORT=$MASTER_MYPORT1,
68 SOURCE_LOG_FILE = '$the_file',
69 SOURCE_LOG_POS = $the_pos ;
70 --enable_result_log
71 --enable_query_log
72 start slave;
73
74 # insert some more values on the first master
75 connection master;
76 INSERT INTO t1 VALUES ("row2","will go away",2),("row3","will change",3),("row4","D",4);
77 DELETE FROM t1 WHERE c3 = 1;
78 UPDATE t1 SET c2="should go away" WHERE c3 = 2;
79 UPDATE t1 SET c2="C" WHERE c3 = 3;
80 DELETE FROM t1 WHERE c3 = 2;
81
82 SELECT * FROM t1 ORDER BY c3;
83
84 # insert another row, and check that we have it on the slave
85 connection server2;
86 INSERT INTO t1 VALUES ("row5","E",5);
87 SELECT * FROM t1 ORDER BY c3;
88 sync_slave_with_master;
89 connection slave;
90 SELECT * FROM t1 ORDER BY c3;
91
92 --echo ==== clean up ====
93 connection server2;
94 DROP TABLE t1;
95 DROP TABLE t2;
96 sync_slave_with_master;
97
98 STOP SLAVE;
99
100 # Reset slave back to first master
101 connection slave;
102 --replace_result $MASTER_MYPORT <MASTER_PORT>
103 eval CHANGE REPLICATION SOURCE TO
104 SOURCE_PORT=$MASTER_MYPORT;
105
106 # Stop the binlog dump threads in server2
107 --connection server2
108 --source include/stop_dump_threads.inc