2003-04-24 15:29:25 +02:00
|
|
|
# When the relay log gets rotated while the I/O thread
|
|
|
|
# is reading a transaction, the transaction spans on two or more
|
|
|
|
# relay logs. If STOP SLAVE occurs while the SQL thread is
|
|
|
|
# executing a part of the transaction in the non-first relay logs,
|
|
|
|
# we test if START SLAVE will resume in the beginning of the
|
|
|
|
# transaction (i.e., step back to the first relay log)
|
|
|
|
|
|
|
|
# The slave is started with max_binlog_size=16384 bytes,
|
|
|
|
# to force many rotations (approximately 30 rotations)
|
|
|
|
|
2004-07-30 01:10:21 +02:00
|
|
|
source include/have_innodb.inc;
|
2003-04-24 15:29:25 +02:00
|
|
|
source include/master-slave.inc;
|
|
|
|
connection slave;
|
|
|
|
stop slave;
|
|
|
|
connection master;
|
2003-06-11 17:07:34 +02:00
|
|
|
--disable_warnings
|
2003-12-10 05:31:42 +01:00
|
|
|
create table t1 (a int) engine=innodb;
|
2003-06-11 17:07:34 +02:00
|
|
|
--enable_warnings
|
2003-04-24 15:29:25 +02:00
|
|
|
let $1=8000;
|
|
|
|
disable_query_log;
|
|
|
|
begin;
|
|
|
|
while ($1)
|
|
|
|
{
|
|
|
|
# eval means expand $ expressions
|
|
|
|
eval insert into t1 values( $1 );
|
|
|
|
dec $1;
|
|
|
|
}
|
|
|
|
commit;
|
|
|
|
# This will generate a 500kB master's binlog,
|
|
|
|
# which corresponds to 30 slave's relay logs.
|
|
|
|
enable_query_log;
|
|
|
|
save_master_pos;
|
|
|
|
connection slave;
|
|
|
|
reset slave;
|
|
|
|
start slave;
|
|
|
|
# We wait 1 sec for the SQL thread to be somewhere in
|
|
|
|
# the middle of the transaction, hopefully not in
|
|
|
|
# the first relay log, and hopefully before the COMMIT.
|
|
|
|
# Usually it stops when the SQL thread is around the 15th relay log.
|
|
|
|
# We cannot use MASTER_POS_WAIT() as master's position
|
|
|
|
# increases only when the slave executes the COMMIT.
|
2003-10-03 22:14:23 +02:00
|
|
|
# Note that except when using Valgrind, 1 second is enough for the I/O slave
|
|
|
|
# thread to fetch the whole master's binlog.
|
2003-08-20 16:32:00 +02:00
|
|
|
sleep 1;
|
2003-04-24 15:29:25 +02:00
|
|
|
stop slave;
|
|
|
|
# We suppose the SQL thread stopped before COMMIT.
|
|
|
|
# If so the transaction was rolled back
|
|
|
|
# and the table is now empty.
|
|
|
|
# Now restart
|
|
|
|
start slave;
|
|
|
|
# And see if the table contains '8000'
|
|
|
|
# which proves that the transaction restarted at
|
|
|
|
# the right place.
|
|
|
|
# We must wait for the transaction to commit before
|
|
|
|
# reading, MASTER_POS_WAIT() will do it for sure
|
|
|
|
# (the only statement with position>=3000 is COMMIT).
|
2003-10-03 20:07:08 +02:00
|
|
|
select master_pos_wait('master-bin.001',3000)>=0;
|
2003-12-19 22:40:23 +01:00
|
|
|
select max(a) from t1;
|
|
|
|
--replace_column 1 # 8 # 9 # 23 # 33 #
|
2003-12-21 18:41:34 +01:00
|
|
|
--replace_result $MASTER_MYPORT MASTER_MYPORT
|
2003-12-19 22:40:23 +01:00
|
|
|
show slave status;
|
2004-04-01 22:47:20 +02:00
|
|
|
connection master;
|
|
|
|
|
2003-05-22 22:29:44 +02:00
|
|
|
# The following DROP is a very important cleaning task:
|
|
|
|
# imagine the next test is run with --skip-innodb: it will do
|
|
|
|
# DROP TABLE IF EXISTS t1; but this will delete the frm and leave
|
|
|
|
# some data in the InnoDB datafile (because at that time mysqld
|
|
|
|
# does not know about InnoDB : --skip-innodb). So if later in the
|
|
|
|
# test suite a test wants to create an InnoDB table called t1, it
|
|
|
|
# will fail with
|
|
|
|
# InnoDB: Error: table t1 already exists in InnoDB internal
|
|
|
|
# InnoDB: data dictionary. Have you deleted the .frm file etc
|
|
|
|
drop table t1;
|
2004-04-01 22:47:20 +02:00
|
|
|
# wait until this drop is executed on slave
|
|
|
|
save_master_pos;
|
|
|
|
connection slave;
|
|
|
|
sync_with_master;
|