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