rpl_ndb_multi.test 2.08 KB
Newer Older
unknown's avatar
unknown committed
1 2 3 4 5 6 7 8 9
--source include/have_ndb.inc
--source include/have_multi_ndb.inc
--source include/have_binlog_format_row.inc
--source include/master-slave.inc

# note: server2 is another "master" connected to the master cluster

#
# Currently test only works with ndb since it retrieves "old"
10
# binlog positions with cluster.binlog_index and apply_status;
unknown's avatar
unknown committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
#

# create a table with one row, and make sure the other "master" gets it
CREATE TABLE t1 (c1 CHAR(15), c2 CHAR(15), c3 INT, PRIMARY KEY (c3)) ENGINE = NDB ;
connection server2;
reset master;
SHOW TABLES;
connection master;
INSERT INTO t1 VALUES ("row1","will go away",1);
SELECT * FROM t1 ORDER BY c3;
connection server2;
SELECT * FROM t1 ORDER BY c3;

# sync slave and retrieve epoch and stop the slave
connection master;
sync_slave_with_master;
--replace_column 1 <the_epoch>
28
SELECT @the_epoch:=MAX(epoch) FROM cluster.apply_status;
unknown's avatar
unknown committed
29 30 31 32 33 34 35 36
let $the_epoch= `select @the_epoch` ;
SELECT * FROM t1 ORDER BY c3;
stop slave;

# get the master binlog pos from the epoch, from the _other_ "master", server2
connection server2;
--replace_result $the_epoch <the_epoch>
eval SELECT @the_pos:=Position,@the_file:=SUBSTRING_INDEX(FILE, '/', -1)
37
   FROM cluster.binlog_index WHERE epoch = $the_epoch ;
unknown's avatar
unknown committed
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
let $the_pos= `SELECT @the_pos` ;
let $the_file= `SELECT @the_file` ;

# now connect the slave to the _other_ "master"
connection slave;
--replace_result $MASTER_MYPORT1 <MASTER_PORT1>
eval CHANGE MASTER TO
  master_port=$MASTER_MYPORT1,
  master_log_file = '$the_file',
  master_log_pos = $the_pos ;
start slave;

# insert some more values on the first master
connection master;
INSERT INTO t1 VALUES ("row2","will go away",2),("row3","will change",3),("row4","D",4);
DELETE FROM t1 WHERE c3 = 1;
UPDATE t1 SET c2="should go away" WHERE c3 = 2;
UPDATE t1 SET c2="C" WHERE c3 = 3;
DELETE FROM t1 WHERE c3 = 2;

SELECT * FROM t1 ORDER BY c3;

save_master_pos;

# insert another row, and check that we have it on the slave
connection server2;
INSERT INTO t1 VALUES ("row5","E",5);
SELECT * FROM t1 ORDER BY c3;
#sync_slave_with_master;
connection slave;
--sleep 2
SELECT * FROM t1 ORDER BY c3;

STOP SLAVE;