| 1 |
--source include/have_multi_ndb.inc |
| 2 |
--source include/have_binlog_format_mixed_or_row.inc |
| 3 |
|
| 4 |
# We need server 3 later on in this test. |
| 5 |
--let $rpl_server_count= 3 |
| 6 |
--source suite/ndb_rpl/ndb_master-slave.inc |
| 7 |
|
| 8 |
--connection master |
| 9 |
|
| 10 |
# note: server2 is another "master" connected to the master cluster |
| 11 |
|
| 12 |
# |
| 13 |
# Currently test only works with ndb since it retrieves "old" |
| 14 |
# binlog positions with mysql.ndb_binlog_index and ndb_apply_status; |
| 15 |
# |
| 16 |
|
| 17 |
# create a table with one row, and make sure the other "master" gets it |
| 18 |
CREATE TABLE t1 (c1 CHAR(15), c2 CHAR(15), c3 INT, PRIMARY KEY (c3)) ENGINE = NDB ; |
| 19 |
# a dummy table such that we can make sure data gets into binlog on server2 |
| 20 |
CREATE TABLE t2 (a int key) ENGINE = NDB ; |
| 21 |
connection server2; |
| 22 |
reset master; |
| 23 |
SHOW TABLES; |
| 24 |
connection master; |
| 25 |
INSERT INTO t1 VALUES ("row1","will go away",1); |
| 26 |
SELECT * FROM t1 ORDER BY c3; |
| 27 |
connection server2; |
| 28 |
SELECT * FROM t1 ORDER BY c3; |
| 29 |
|
| 30 |
# sync slave and retrieve epoch and stop the slave |
| 31 |
connection master; |
| 32 |
sync_slave_with_master; |
| 33 |
SELECT MAX(epoch) FROM mysql.ndb_apply_status into @the_epoch; |
| 34 |
--replace_column 1 <the_epoch> |
| 35 |
SELECT @the_epoch; |
| 36 |
let $the_epoch= `select @the_epoch` ; |
| 37 |
SELECT * FROM t1 ORDER BY c3; |
| 38 |
stop slave; |
| 39 |
|
| 40 |
# get the master binlog pos from the epoch, from the _other_ "master", server2 |
| 41 |
connection server2; |
| 42 |
# insert some data to t1 which should not come into the binlog |
| 43 |
# just so that we can do "show binlog events" to make sure the t1 |
| 44 |
# update is actually in the server2 binlog |
| 45 |
set SQL_LOG_BIN=0; |
| 46 |
insert into t2 values (1); |
| 47 |
-- source include/show_binlog_events.inc |
| 48 |
set SQL_LOG_BIN=1; |
| 49 |
--replace_result $the_epoch <the_epoch> |
| 50 |
--disable_query_log |
| 51 |
--disable_result_log |
| 52 |
eval SELECT @the_pos:=Position, |
| 53 |
@the_file:=SUBSTRING_INDEX(REPLACE(FILE,'\\\\','/'), '/', -1) |
| 54 |
FROM mysql.ndb_binlog_index WHERE epoch = $the_epoch ; |
| 55 |
--enable_result_log |
| 56 |
--enable_query_log |
| 57 |
let $the_pos= `SELECT @the_pos` ; |
| 58 |
let $the_file= `SELECT @the_file` ; |
| 59 |
|
| 60 |
# now connect the slave to the _other_ "master" |
| 61 |
--let $rpl_topology= 3->2 |
| 62 |
--let $rpl_master_log_file= 2:$the_file |
| 63 |
--let $rpl_master_log_pos= 2:$the_pos |
| 64 |
--source include/rpl_change_topology.inc |
| 65 |
--connection slave |
| 66 |
--source include/start_slave.inc |
| 67 |
|
| 68 |
# insert some more values on the first master |
| 69 |
connection master; |
| 70 |
INSERT INTO t1 VALUES ("row2","will go away",2),("row3","will change",3),("row4","D",4); |
| 71 |
DELETE FROM t1 WHERE c3 = 1; |
| 72 |
UPDATE t1 SET c2="should go away" WHERE c3 = 2; |
| 73 |
UPDATE t1 SET c2="C" WHERE c3 = 3; |
| 74 |
DELETE FROM t1 WHERE c3 = 2; |
| 75 |
|
| 76 |
SELECT * FROM t1 ORDER BY c3; |
| 77 |
|
| 78 |
# insert another row, and check that we have it on the slave |
| 79 |
connection server2; |
| 80 |
INSERT INTO t1 VALUES ("row5","E",5); |
| 81 |
SELECT * FROM t1 ORDER BY c3; |
| 82 |
sync_slave_with_master; |
| 83 |
SELECT * FROM t1 ORDER BY c3; |
| 84 |
|
| 85 |
--echo ==== clean up ==== |
| 86 |
connection server2; |
| 87 |
DROP TABLE t1; |
| 88 |
DROP TABLE t2; |
| 89 |
sync_slave_with_master; |
| 90 |
|
| 91 |
--source include/rpl_end.inc |