~ubuntu-branches/ubuntu/maverick/mysql-5.1/maverick-proposed

« back to all changes in this revision

Viewing changes to mysql-test/suite/bugs/t/rpl_bug38205.test

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 14:16:05 UTC
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: package-import@ubuntu.com-20120222141605-nxlu9yzc6attylc2
Tags: upstream-5.1.61
ImportĀ upstreamĀ versionĀ 5.1.61

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#
2
 
# Bug #38205 Row-based Replication (RBR) causes inconsistencies: HA_ERR_FOUND_DUPP_KEY
3
 
# Bug#319  if while a non-transactional slave is replicating a transaction possible problem 
4
 
#
5
 
# Verifying the fact that STOP SLAVE in the middle of a group execution waits
6
 
# for the end of the group before the slave sql thread will stop.
7
 
# The patch refines STOP SLAVE to not interrupt a transaction or other type of 
8
 
# the replication events group (the part I).
9
 
# Killing the sql thread continues to provide a "hard" stop (the part II).
10
 
#
11
 
# Non-deterministic tests
12
 
#
13
 
 
14
 
source include/master-slave.inc;
15
 
source include/have_innodb.inc;
16
 
 
17
 
 
18
 
#
19
 
# Part II, killed sql slave leaves instantly
20
 
#
21
 
 
22
 
# A. multi-statement transaction as the replication group
23
 
 
24
 
connection master;
25
 
 
26
 
create table t1i(n int primary key) engine=innodb;
27
 
create table t2m(n int primary key) engine=myisam;
28
 
 
29
 
sync_slave_with_master;
30
 
 
31
 
connection master;
32
 
 
33
 
begin;
34
 
insert into t1i values (1);
35
 
insert into t1i values (2);
36
 
insert into t1i values (3);
37
 
commit;
38
 
 
39
 
sync_slave_with_master;
40
 
 
41
 
#
42
 
# todo: first challenge is to find out the SQL thread id
43
 
# the following is not fully reliable
44
 
#
45
 
 
46
 
let $id=`SELECT id from information_schema.processlist where user like 'system user' and state like '%Has read all relay log%' or user like 'system user' and state like '%Reading event from the relay log%'`;
47
 
connection slave;
48
 
begin;
49
 
insert into t1i values (5);
50
 
 
51
 
connection master;
52
 
let $pos0_master= query_get_value(SHOW MASTER STATUS, Position, 1);
53
 
begin;
54
 
insert into t1i values (4);
55
 
insert into t2m values (1); # non-ta update
56
 
update t1i set n = 5 where n = 4; # to block at. can't be played with killed
57
 
commit;
58
 
let $pos1_master= query_get_value(SHOW MASTER STATUS, Position, 1);
59
 
 
60
 
connection slave;
61
 
# slave sql thread must be locked out by the conn `slave' explicit lock
62
 
let $pos0_slave= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
63
 
--disable_query_log
64
 
eval select $pos0_master - $pos0_slave as zero;
65
 
--enable_query_log
66
 
 
67
 
connection slave1;
68
 
 
69
 
let $count= 1;
70
 
let $table= t2m;
71
 
source include/wait_until_rows_count.inc;
72
 
#
73
 
# todo: may fail as said above
74
 
#
75
 
--echo *** kill sql thread ***
76
 
--disable_query_log
77
 
eval kill connection $id;
78
 
--enable_query_log
79
 
 
80
 
connection slave;
81
 
rollback; # release the sql thread
82
 
 
83
 
connection slave1;
84
 
 
85
 
source include/wait_for_slave_sql_to_stop.inc;
86
 
let $sql_status= query_get_value(SHOW SLAVE STATUS, Slave_SQL_Running, 1);
87
 
--echo *** sql thread is *not* running: $sql_status ***
88
 
let $pos1_slave= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
89
 
 
90
 
connection slave;
91
 
--echo *** the prove: the killed slave has not finished the current transaction ***
92
 
 
93
 
--disable_query_log
94
 
select count(*) as three from t1i;
95
 
eval select $pos1_master > $pos1_slave as one;
96
 
eval select $pos1_slave - $pos0_slave as zero;
97
 
--enable_query_log
98
 
 
99
 
delete from t2m; # remove the row to be able to replay
100
 
start slave sql_thread;
101
 
 
102
 
#
103
 
# Part I: B The homogenous transaction remains interuptable in between
104
 
#
105
 
 
106
 
connection master;
107
 
delete from t1i;
108
 
delete from t2m;
109
 
 
110
 
sync_slave_with_master;
111
 
begin;
112
 
insert into t1i values (5);
113
 
 
114
 
connection master;
115
 
let $pos0_master= query_get_value(SHOW MASTER STATUS, Position, 1);
116
 
begin;
117
 
insert into t1i values (4);
118
 
update t1i set n = 5 where n = 4; # to block at. not to be played
119
 
commit;
120
 
let $pos1_master= query_get_value(SHOW MASTER STATUS, Position, 1);
121
 
 
122
 
 
123
 
connection slave1;
124
 
# slave sql can't advance as must be locked by the conn `slave' trans
125
 
let $pos0_slave= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
126
 
--disable_query_log
127
 
eval select $pos0_master - $pos0_slave as zero;
128
 
--enable_query_log
129
 
 
130
 
#
131
 
# the replicated trans is blocked by the slave's local.
132
 
# However, it's not easy to catch the exact moment when it happens.
133
 
# The test issues sleep which makes the test either non-deterministic or
134
 
# wasting too much time.
135
 
#
136
 
--sleep 3
137
 
 
138
 
send stop slave sql_thread;
139
 
 
140
 
connection slave;
141
 
rollback; # release the sql thread
142
 
 
143
 
connection slave1;
144
 
reap;
145
 
source include/wait_for_slave_sql_to_stop.inc;
146
 
let $sql_status= query_get_value(SHOW SLAVE STATUS, Slave_SQL_Running, 1);
147
 
--echo *** sql thread is *not* running: $sql_status ***
148
 
 
149
 
let $pos1_slave= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
150
 
 
151
 
--echo *** the prove: the stopped slave has rolled back the current transaction ***
152
 
 
153
 
--disable_query_log
154
 
select count(*) as zero from t1i;
155
 
eval select $pos0_master - $pos0_slave as zero;
156
 
eval select $pos1_master > $pos0_slave as one;
157
 
--enable_query_log
158
 
 
159
 
start slave sql_thread;
160
 
 
161
 
# clean-up
162
 
 
163
 
connection master;
164
 
drop table t1i, t2m;
165
 
 
166
 
sync_slave_with_master;