MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ndb_rpl_xxx_innodb.inc
1 #############################################
2 #Authors: TU and Jeb
3 #Date: 2007/04
4 #Purpose: Generic replication to cluster
5 # and ensuring that the ndb_apply_status
6 # table is updated.
7 #############################################
8 # Notes:
9 # select_ndb_apply_status.inc
10 # Selects out the log name, start & end pos
11 # from the ndb_apply_status table
12 #
13 # include/show_binlog_using_logname.inc
14 # To select out 1 row from offset 1
15 # from the start position in the binlog whose
16 # name is = log_name
17 #
18 # include/tpcb.inc
19 # Creates DATABASE tpcb, the tables and
20 # stored procedures for loading the DB
21 # and for running transactions against DB.
22 ##############################################
23 
24 
25 --echo
26 --echo *** Test 1 ***
27 --echo
28 
29 connection master;
30 create table t1 (a int key, b int) engine innodb;
31 create table t2 (a int key, b int) engine innodb;
32 
33 --echo
34 
35 --sync_slave_with_master
36 alter table t1 engine ndb;
37 alter table t2 engine ndb;
38 
39 --echo
40 
41 # check binlog position without begin
42 connection master;
43 insert into t1 values (1,2);
44 
45 --echo
46 
47 --sync_slave_with_master
48 --source suite/ndb_rpl/t/select_ndb_apply_status.inc
49 
50 --echo
51 
52 connection master;
53 --echo # Now check that that is in the apply_status table is consistant
54 --echo # with what is in the binlog
55 --echo
56 --echo # since insert is done with transactional engine, expect a BEGIN
57 --echo # at <start_pos>
58 --echo
59 --let $binlog_start= $start_pos
60 --let $binlog_limit= 1
61 --source include/show_binlog_events.inc
62 
63 --echo
64 --echo # Now the insert, one step after
65 --echo
66 --let $binlog_start= $start_pos
67 --let $binlog_limit= 1,1
68 --source include/show_binlog_events.inc
69 
70 --echo
71 --echo # and the COMMIT should be at <end_pos>
72 --echo
73 --let $binlog_start= $start_pos
74 --let $binlog_limit= 2,1
75 --source include/show_binlog_events.inc
76 
77 --echo
78 
79 # check binlog position with begin
80 begin;
81 insert into t1 values (2,3);
82 insert into t2 values (3,4);
83 commit;
84 
85 --echo
86 
87 --sync_slave_with_master
88 --source suite/ndb_rpl/t/select_ndb_apply_status.inc
89 
90 connection master;
91 --let $binlog_start= $start_pos
92 --let $binlog_limit= 1
93 --source include/show_binlog_events.inc
94 --echo
95 --let $binlog_start= $start_pos
96 --let $binlog_limit= 1,2
97 --source include/show_binlog_events.inc
98 --echo
99 --let $binlog_start= $start_pos
100 --let $binlog_limit= 3,1
101 --source include/show_binlog_events.inc
102 
103 --echo
104 
105 connection master;
106 DROP TABLE test.t1, test.t2;
107 --sync_slave_with_master
108 SHOW TABLES;
109 
110 # Run in some transactions using stored procedures
111 # and ensure that the ndb_apply_status table is
112 # updated to show the transactions
113 
114 
115 --echo
116 --echo *** Test 2 ***
117 --echo
118 
119 # Create database/tables and stored procdures
120 connection master;
121 --source include/tpcb.inc
122 
123 # Switch tables on slave to use NDB
124 --sync_slave_with_master
125 USE tpcb;
126 ALTER TABLE account ENGINE NDB;
127 ALTER TABLE branch ENGINE NDB;
128 ALTER TABLE teller ENGINE NDB;
129 ALTER TABLE history ENGINE NDB;
130 
131 --echo
132 
133 # Load DB tpcb and run some transactions
134 connection master;
135 --disable_query_log
136 CALL tpcb.load();
137 SET AUTOCOMMIT=0;
138 let $run= 5;
139 while ($run)
140 {
141  START TRANSACTION;
142  --eval CALL tpcb.trans($rpl_format);
143  eval SET @my_errno= $mysql_errno;
144  let $run_good= `SELECT @my_errno = 0`;
145  let $run_bad= `SELECT @my_errno <> 0`;
146  if ($run_good)
147  {
148  COMMIT;
149  }
150  if ($run_bad)
151  {
152  ROLLBACK;
153  }
154  dec $run;
155 }
156 
157 SET AUTOCOMMIT=1;
158 --enable_query_log
159 
160 --sync_slave_with_master
161 --source suite/ndb_rpl/t/select_ndb_apply_status.inc
162 
163 --echo
164 
165 connection master;
166 --source include/show_binlog_using_logname.inc
167 
168 # Flush the logs on the master moving all
169 # Transaction to a new binlog and ensure
170 # that the ndb_apply_status table is updated
171 # to show the use of the new binlog.
172 
173 --echo
174 --echo ** Test 3 **
175 --echo
176 
177 # Flush logs on master which should force it
178 # to switch to binlog #2
179 
180 FLUSH LOGS;
181 
182 # Run in some transaction to increase end pos in
183 # binlog
184 
185 --disable_query_log
186 SET AUTOCOMMIT=0;
187 let $run= 5;
188 while ($run)
189 {
190  START TRANSACTION;
191  --eval CALL tpcb.trans($rpl_format);
192  eval SET @my_errno= $mysql_errno;
193  let $run_good= `SELECT @my_errno = 0`;
194  let $run_bad= `SELECT @my_errno <> 0`;
195  if ($run_good)
196  {
197  COMMIT;
198  }
199  if ($run_bad)
200  {
201  ROLLBACK;
202  }
203  dec $run;
204 }
205 SET AUTOCOMMIT=1;
206 --enable_query_log
207 
208 --echo
209 
210 --sync_slave_with_master
211 --source suite/ndb_rpl/t/select_ndb_apply_status.inc
212 
213 --echo
214 
215 connection master;
216 --source include/show_binlog_using_logname.inc
217 
218 # Now we reset both the master and the slave
219 # Run some more transaction and ensure
220 # that the ndb_apply_status is updated
221 # correctly
222 
223 --echo
224 --echo ** Test 4 **
225 --echo
226 
227 # Reset both slave and master
228 # This should reset binlog to #1
229 --source include/rpl_reset.inc
230 
231 --echo
232 
233 # Run in some transactions and check
234 connection master;
235 --disable_query_log
236 SET AUTOCOMMIT=0;
237 let $run= 5;
238 while ($run)
239 {
240  START TRANSACTION;
241  --eval CALL tpcb.trans($rpl_format);
242  eval SET @my_errno= $mysql_errno;
243  let $run_good= `SELECT @my_errno = 0`;
244  let $run_bad= `SELECT @my_errno <> 0`;
245  if ($run_good)
246  {
247  COMMIT;
248  }
249  if ($run_bad)
250  {
251  ROLLBACK;
252  }
253  dec $run;
254 }
255 SET AUTOCOMMIT=1;
256 --enable_query_log
257 
258 --sync_slave_with_master
259 --source suite/ndb_rpl/t/select_ndb_apply_status.inc
260 
261 --echo
262 
263 connection master;
264 --source include/show_binlog_using_logname.inc
265 
266 # Since we are doing replication, it is a good
267 # idea to check to make sure all data was
268 # Replicated correctly
269 
270 --echo
271 --echo *** DUMP MASTER & SLAVE FOR COMPARE ********
272 
273 --exec $MYSQL_DUMP -n -t --compact --order-by-primary --skip-extended-insert tpcb account teller branch history > $MYSQLTEST_VARDIR/tmp/master_apply_status.sql
274 
275 --exec $MYSQL_DUMP_SLAVE -n -t --compact --order-by-primary --skip-extended-insert tpcb account teller branch history > $MYSQLTEST_VARDIR/tmp/slave_apply_status.sql
276 
277 connection master;
278 DROP DATABASE tpcb;
279 
280 --sync_slave_with_master
281 
282 ####### Commenting out until decision on Bug#27960 ###########
283 
284 #--source suite/ndb_rpl/t/select_ndb_apply_status.inc
285 
286 #connection master;
287 #--eval SHOW BINLOG EVENTS in '$log_name' from $start_pos
288 #--source include/show_binlog_using_logname.inc
289 
290 --echo ****** Do dumps compare ************
291 
292 
293 diff_files $MYSQLTEST_VARDIR/tmp/master_apply_status.sql $MYSQLTEST_VARDIR/tmp/slave_apply_status.sql;
294 
295 ## Note: Ths files should only get removed, if the above diff succeeds.
296 
297 --remove_file $MYSQLTEST_VARDIR/tmp/master_apply_status.sql
298 --remove_file $MYSQLTEST_VARDIR/tmp/slave_apply_status.sql
299 
300 
301 # End of 5.1 Test