Debian Codegraph @

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

raw
1 --source include/have_ndb.inc
2
3 # set up circular replication
4 --let $rpl_topology= 1->2->1
5 --source include/rpl_init.inc
6
7 --let $rpl_connection_name= master
8 --let $rpl_server_number= 1
9 --source include/rpl_connect.inc
10
11 --let $rpl_connection_name= slave
12 --let $rpl_server_number= 2
13 --source include/rpl_connect.inc
14
15
16 # create the table on the "slave"
17 --connection slave
18 CREATE TABLE t1 (a int key, b int) ENGINE=ndb;
19 #CREATE TABLE t2 (a int key, b int) ENGINE=ndb;
20 sync_slave_with_master master;
21 # now we should have a table on the master as well
22 SHOW TABLES;
23
24 # insert some values on the slave and master
25 --connection master
26 INSERT INTO t1 VALUES (1,2);
27 # Give time to propagate + close epoch, to ensure deterministic Binlog contents
28 --sleep 1
29 --connection slave
30 INSERT INTO t1 VALUES (2,3);
31
32 # ensure data has propagated both ways
33 --connection slave
34 sync_slave_with_master master;
35 --sync_slave_with_master
36
37 # connect to slave and ensure data it there.
38 --connection slave
39 SELECT * FROM t1 ORDER BY a;
40 #SELECT * FROM t2 ORDER BY a;
41
42 # Check slave has no errors and are running
43 --source include/check_slave_no_error.inc
44 --source include/check_slave_is_running.inc
45
46 --echo Slave Binlog contains all ops as log_replica_updates is on
47 show variables like 'server_id';
48 show variables like 'log_bin';
49 show variables like 'log_replica_updates';
50 --source include/show_binlog_events.inc
51
52 source include/check_slave_is_running.inc;
53 # connect to master and ensure data it there.
54 --connection master
55 SELECT * FROM t1 ORDER BY a;
56 #SELECT * FROM t2 ORDER BY a;
57 source include/check_slave_is_running.inc;
58
59 --echo Master Binlog contains only Master ops as log_replica_updates is off
60 show variables like 'server_id';
61 show variables like 'log_bin';
62 show variables like 'log_replica_updates';
63 --source include/show_binlog_events.inc
64
65 # stop replication on "master" as not to replicate
66 # shutdown circularly, eg drop table
67 --connection master
68 STOP SLAVE;
69
70 # cleanup
71 --connection master
72 DROP TABLE t1;
73 -- sync_slave_with_master
74
75 # Test ndb_log_apply_status option
76
77 --connection master
78 start slave;
79 create table t1 (a int primary key, b int) engine=ndb;
80 show variables like '%log_orig%';
81
82 --echo 'Master' has only slave's serverid entry
83 select server_id, log_name from mysql.ndb_apply_status order by server_id;
84
85 set global ndb_log_apply_status=On;
86 show variables like 'ndb_log_apply_status';
87
88 --connection slave
89 --echo 'Slave' has only Master's serverid entry
90 select server_id, log_name from mysql.ndb_apply_status order by server_id;
91 --echo 'Slave' has following ndb_binlog_index entries
92 select inserts, updates, deletes, schemaops, orig_server_id from mysql.ndb_binlog_index order by position,orig_epoch;
93
94 set global ndb_log_apply_status=On;
95 show variables like 'ndb_log_apply_status';
96
97 --connection master
98
99 stop slave;
100 insert into t1 values (1,1);
101 --sync_slave_with_master
102
103 --connection slave
104 --echo 'Slave' still has only Master's serverid entry
105 select server_id, log_name from mysql.ndb_apply_status order by server_id;
106
107 --disable_result_log
108 --source include/wait_for_ndb_committed_to_binlog.inc
109 --enable_result_log
110 --echo 'Slave' has following ndb_binlog_index entries
111 select inserts, updates, deletes, schemaops, orig_server_id from mysql.ndb_binlog_index order by position,orig_epoch;
112
113 --connection master
114 --echo 'Master' still has only Slave's serverid entry
115 select server_id, log_name from mysql.ndb_apply_status order by server_id;
116
117 start slave;
118 --connection slave
119 --sync_slave_with_master master
120
121 --connection master
122 --echo 'Master' now has own serverid entry as well.
123 select server_id, log_name from mysql.ndb_apply_status order by server_id;
124
125 --connection slave
126 --echo 'Slave' still only has 'Master''s serverid entry
127 select server_id, log_name from mysql.ndb_apply_status order by server_id;
128 --echo Now create event originating at Slave
129 insert into t1 values (2,2);
130 --sync_slave_with_master master
131
132 --connection master
133 --sync_slave_with_master slave
134
135 --connection slave
136 --echo 'Slave' now also has its own serverid entry
137 select server_id, log_name from mysql.ndb_apply_status order by server_id;
138
139
140 --connection master
141 stop slave;
142 set global ndb_log_apply_status=off;
143
144 --connection slave
145 set global ndb_log_apply_status=off;
146 stop slave;
147
148 drop table t1;
149
150 --connection master
151
152 drop table t1;
153
154 --let $rpl_only_running_threads= 1
155 --source include/rpl_end.inc