1
by brian
clean slate |
1 |
# When the relay log gets rotated while the I/O thread |
2 |
# is reading a transaction, the transaction spans on two or more |
|
3 |
# relay logs. If STOP SLAVE occurs while the SQL thread is |
|
4 |
# executing a part of the transaction in the non-first relay logs, |
|
5 |
# we test if START SLAVE will resume in the beginning of the |
|
6 |
# transaction (i.e., step back to the first relay log) |
|
7 |
||
8 |
# The slave is started with max_binlog_size=16384 bytes, |
|
9 |
# to force many rotations (approximately 30 rotations) |
|
10 |
||
11 |
# We have to sync with master, to ensure slave had time to start properly |
|
12 |
# before we stop it. If not, we get errors about UNIX_TIMESTAMP() in the log. |
|
13 |
connection master; |
|
14 |
sync_slave_with_master; |
|
15 |
connection slave; |
|
16 |
stop slave; |
|
17 |
connection master; |
|
18 |
--disable_warnings
|
|
19 |
eval create table t1 (a int) engine=$engine_type; |
|
20 |
--enable_warnings
|
|
21 |
let $1=8000; |
|
22 |
disable_query_log; |
|
23 |
begin; |
|
24 |
while ($1) |
|
25 |
{
|
|
26 |
# eval means expand $ expressions |
|
27 |
eval insert into t1 values( $1 ); |
|
28 |
dec $1; |
|
29 |
}
|
|
30 |
commit; |
|
31 |
# This will generate a 500kB master's binlog, |
|
32 |
# which corresponds to 30 slave's relay logs. |
|
33 |
enable_query_log; |
|
34 |
save_master_pos; |
|
35 |
connection slave; |
|
36 |
reset slave; |
|
37 |
start slave; |
|
38 |
# We wait 1 sec for the SQL thread to be somewhere in |
|
39 |
# the middle of the transaction, hopefully not in |
|
40 |
# the first relay log, and hopefully before the COMMIT. |
|
41 |
# Usually it stops when the SQL thread is around the 15th relay log. |
|
42 |
# We cannot use MASTER_POS_WAIT() as master's position |
|
43 |
# increases only when the slave executes the COMMIT.
|
|
44 |
# Note that except when using Valgrind, 1 second is enough for the I/O slave
|
|
45 |
# thread to fetch the whole master's binlog. |
|
46 |
sleep 1; |
|
47 |
stop slave; |
|
48 |
# We suppose the SQL thread stopped before COMMIT. |
|
49 |
# If so the transaction was rolled back |
|
50 |
# and the table is now empty. |
|
51 |
# Now restart |
|
52 |
start slave; |
|
53 |
# And see if the table contains '8000' |
|
54 |
# which proves that the transaction restarted at |
|
55 |
# the right place. |
|
56 |
# We must wait for the transaction to commit before |
|
57 |
# reading, with a sync_with_master. |
|
58 |
sync_with_master; |
|
59 |
select max(a) from t1; |
|
60 |
connection master; |
|
61 |
||
62 |
# The following DROP is a very important cleaning task: |
|
63 |
# imagine the next test is run with --skip-innodb: it will do |
|
64 |
# DROP TABLE IF EXISTS t1; but this will delete the frm and leave |
|
65 |
# some data in the InnoDB datafile (because at that time mysqld |
|
66 |
# does not know about InnoDB : --skip-innodb). So if later in the |
|
67 |
# test suite a test wants to create an InnoDB table called t1, it |
|
68 |
# will fail with |
|
69 |
# InnoDB: Error: table t1 already exists in InnoDB internal |
|
70 |
# InnoDB: data dictionary. Have you deleted the .frm file etc |
|
71 |
drop table t1; |
|
72 |
# wait until this drop is executed on slave |
|
73 |
save_master_pos; |
|
74 |
connection slave; |
|
75 |
sync_with_master; |
|
76 |
||
77 |
# End of 4.1 tests |