~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to mysql-test/suite/rpl_ndb/t/rpl_ndb_multi.test

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--source include/have_multi_ndb.inc
 
2
--source include/have_binlog_format_mixed_or_row.inc
 
3
--source include/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
connection server2;
 
15
reset master;
 
16
SHOW TABLES;
 
17
connection master;
 
18
INSERT INTO t1 VALUES ("row1","will go away",1);
 
19
SELECT * FROM t1 ORDER BY c3;
 
20
connection server2;
 
21
SELECT * FROM t1 ORDER BY c3;
 
22
 
 
23
# sync slave and retrieve epoch and stop the slave
 
24
connection master;
 
25
sync_slave_with_master;
 
26
--replace_column 1 <the_epoch>
 
27
SELECT @the_epoch:=MAX(epoch) FROM mysql.ndb_apply_status;
 
28
let $the_epoch= `select @the_epoch` ;
 
29
SELECT * FROM t1 ORDER BY c3;
 
30
stop slave;
 
31
 
 
32
# get the master binlog pos from the epoch, from the _other_ "master", server2
 
33
connection server2;
 
34
--replace_result $the_epoch <the_epoch>
 
35
eval SELECT @the_pos:=Position,@the_file:=SUBSTRING_INDEX(FILE, '/', -1)
 
36
   FROM mysql.ndb_binlog_index WHERE epoch = $the_epoch ;
 
37
let $the_pos= `SELECT @the_pos` ;
 
38
let $the_file= `SELECT @the_file` ;
 
39
 
 
40
# now connect the slave to the _other_ "master"
 
41
connection slave;
 
42
--replace_result $MASTER_MYPORT1 <MASTER_PORT1>
 
43
eval CHANGE MASTER TO
 
44
  master_port=$MASTER_MYPORT1,
 
45
  master_log_file = '$the_file',
 
46
  master_log_pos = $the_pos ;
 
47
start slave;
 
48
 
 
49
# insert some more values on the first master
 
50
connection master;
 
51
INSERT INTO t1 VALUES ("row2","will go away",2),("row3","will change",3),("row4","D",4);
 
52
DELETE FROM t1 WHERE c3 = 1;
 
53
UPDATE t1 SET c2="should go away" WHERE c3 = 2;
 
54
UPDATE t1 SET c2="C" WHERE c3 = 3;
 
55
DELETE FROM t1 WHERE c3 = 2;
 
56
 
 
57
SELECT * FROM t1 ORDER BY c3;
 
58
 
 
59
# insert another row, and check that we have it on the slave
 
60
connection server2;
 
61
INSERT INTO t1 VALUES ("row5","E",5);
 
62
SELECT * FROM t1 ORDER BY c3;
 
63
sync_slave_with_master;
 
64
connection slave;
 
65
SELECT * FROM t1 ORDER BY c3;
 
66
 
 
67
--echo ==== clean up ====
 
68
connection server2;
 
69
DROP TABLE t1;
 
70
sync_slave_with_master;
 
71
 
 
72
STOP SLAVE;