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
|
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
connect con1, localhost, root,,;
connect con2, localhost, root,,;
create table t1 (a int auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB;
create table t2 (a int auto_increment, b int, PRIMARY KEY (a)) ENGINE=MyISAM;
create table t3 (a int auto_increment, b int, PRIMARY KEY (a)) ENGINE=InnoDB;
connection con1;
select get_lock("a", 20);
get_lock("a", 20)
1
connection con2;
reset master;
insert into t2 values (null, null), (null, get_lock("a", 10));
connection con1;
kill query ID;
connection con2;
select
(@a:=load_file("MYSQLTEST_VARDIR/tmp/kill_query_calling_sp.binlog"))
is not null;
set @result= 2 - 1 - 1;
select @result /* must be zero either way */;
@result
0
connection con1;
select RELEASE_LOCK("a");
RELEASE_LOCK("a")
1
delete from t1;
delete from t2;
insert into t1 values (1,1),(2,2);
connection con1;
begin;
update t1 set b=11 where a=2;
connection con2;
begin;
update t1 set b=b+10;
connection con1;
kill query ID;
rollback;
connection con2;
rollback;
select * from t1 order by a /* must be the same as before (1,1),(2,2) */;
a b
1 1
2 2
connection con1;
begin;
delete from t1 where a=2;
connection con2;
begin;
delete from t1 where a=2;
connection con1;
kill query ID;
rollback;
connection con2;
rollback;
select * from t1 order by a /* must be the same as before (1,1),(2,2) */;
a b
1 1
2 2
connection con1;
drop table if exists t4;
create table t4 (a int, b int) engine=innodb;
insert into t4 values (3, 3);
begin;
insert into t1 values (3, 3);
connection con2;
begin;
insert into t1 select * from t4 for update;
connection con1;
kill query ID;
rollback;
connection con2;
rollback;
select * from t1 /* must be the same as before (1,1),(2,2) */;
a b
1 1
2 2
drop table t4;
create table t4 (a int, b int) ENGINE=MyISAM /* for killing update and delete */;
create function bug27563(n int)
RETURNS int(11)
NOT DETERMINISTIC
begin
if @b > 0 then
select get_lock("a", 20) into @a;
else
set @b= 1;
end if;
return n;
end|
delete from t4;
insert into t4 values (1,1), (1,1);
reset master;
connection con1;
select get_lock("a", 20);
get_lock("a", 20)
1
connection con2;
set @b= 0;
update t4 set b=b + bug27563(b);
connection con1;
select count(*) FROM INFORMATION_SCHEMA.PROCESSLIST where state='User lock';
count(*)
1
kill query ID;
connection con2;
ERROR 70100: Query execution was interrupted
select * from t4 order by b /* must be (1,1), (1,2) */;
a b
1 1
1 2
select @b /* must be 1 at the end of a stmt calling bug27563() */;
@b
1
must have the update query event on the 4th line
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # User var # # @`b`=0
master-bin.000001 # Query # # use `test`; update t4 set b=b + bug27563(b)
master-bin.000001 # Query # # COMMIT
*** a proof the query is binlogged with an error ***
select
(@a:=load_file("MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog"))
is not null;
(@a:=load_file("MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog"))
is not null
1
select 0 /* must return 0 to mean the killed update is in */;
0
0
connection con1;
select RELEASE_LOCK("a");
RELEASE_LOCK("a")
1
delete from t4;
insert into t4 values (1,1), (2,2);
reset master;
connection con1;
select get_lock("a", 20);
get_lock("a", 20)
1
connection con2;
set @b= 0;
delete from t4 where b=bug27563(1) or b=bug27563(2);
connection con1;
select count(*) FROM INFORMATION_SCHEMA.PROCESSLIST where state='User lock';
count(*)
1
kill query ID;
connection con2;
ERROR 70100: Query execution was interrupted
select count(*) from t4 /* must be 1 */;
count(*)
1
select @b /* must be 1 at the end of a stmt calling bug27563() */;
@b
1
must have the delete query event on the 4th line
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Gtid # # BEGIN GTID #-#-#
master-bin.000001 # User var # # @`b`=0
master-bin.000001 # Query # # use `test`; delete from t4 where b=bug27563(1) or b=bug27563(2)
master-bin.000001 # Query # # COMMIT
select
(@a:=load_file("MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog"))
is not null;
(@a:=load_file("MYSQLTEST_VARDIR/tmp/binlog_killed_bug27571.binlog"))
is not null
1
select 0 /* must return 0 to mean the killed delete is in */;
0
0
connection con1;
select RELEASE_LOCK("a");
RELEASE_LOCK("a")
1
drop table t4;
drop function bug27563;
FLUSH LOGS;
connect con3, localhost, root,,;
connection con3;
MI: MyISAM, INNODB
BEGIN;
INSERT INTO t2 VALUES (NULL, 1);
INSERT INTO t1 VALUES (NULL, 2);
connection con1;
KILL ID;
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000002 # Format_desc # # SERVER_VERSION, BINLOG_VERSION
master-bin.000002 # Gtid_list # # [#-#-#]
master-bin.000002 # Gtid # # BEGIN GTID #-#-#
master-bin.000002 # Intvar # # INSERT_ID=3
master-bin.000002 # Query # # use `test`; INSERT INTO t2 VALUES (NULL, 1)
master-bin.000002 # Query # # COMMIT
master-bin.000002 # Gtid # # BEGIN GTID #-#-#
master-bin.000002 # Intvar # # INSERT_ID=4
master-bin.000002 # Query # # use `test`; INSERT INTO t1 VALUES (NULL, 2)
master-bin.000002 # Query # # ROLLBACK
disconnect con3;
connect con3, localhost, root,,;
connection con3;
IM: INNODB, MyISAM
BEGIN;
INSERT INTO t1 VALUES (NULL, 3);
INSERT INTO t2 VALUES (NULL, 4);
connection con1;
KILL ID;
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000002 # Gtid # # BEGIN GTID #-#-#
master-bin.000002 # Intvar # # INSERT_ID=4
master-bin.000002 # Query # # use `test`; INSERT INTO t2 VALUES (NULL, 4)
master-bin.000002 # Query # # COMMIT
master-bin.000002 # Gtid # # BEGIN GTID #-#-#
master-bin.000002 # Intvar # # INSERT_ID=5
master-bin.000002 # Query # # use `test`; INSERT INTO t1 VALUES (NULL, 3)
master-bin.000002 # Query # # ROLLBACK
disconnect con3;
connect con3, localhost, root,,;
connection con3;
IMI: INNODB, MyISAM, INNODB
BEGIN;
INSERT INTO t1 VALUES (NULL, 5);
INSERT INTO t2 VALUES (NULL, 6);
INSERT INTO t1 VALUES (NULL, 7);
connection con1;
KILL ID;
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000002 # Gtid # # BEGIN GTID #-#-#
master-bin.000002 # Intvar # # INSERT_ID=5
master-bin.000002 # Query # # use `test`; INSERT INTO t2 VALUES (NULL, 6)
master-bin.000002 # Query # # COMMIT
master-bin.000002 # Gtid # # BEGIN GTID #-#-#
master-bin.000002 # Intvar # # INSERT_ID=6
master-bin.000002 # Query # # use `test`; INSERT INTO t1 VALUES (NULL, 5)
master-bin.000002 # Intvar # # INSERT_ID=7
master-bin.000002 # Query # # use `test`; INSERT INTO t1 VALUES (NULL, 7)
master-bin.000002 # Query # # ROLLBACK
disconnect con3;
connect con3, localhost, root,,;
connection con3;
MI2: MyISAM, INNODB, MyISAM, INNODB
BEGIN;
INSERT INTO t2 VALUES (NULL, 8);
INSERT INTO t1 VALUES (NULL, 9);
INSERT INTO t2 VALUES (NULL, 10);
INSERT INTO t1 VALUES (NULL, 11);
connection con1;
KILL ID;
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000002 # Gtid # # BEGIN GTID #-#-#
master-bin.000002 # Intvar # # INSERT_ID=6
master-bin.000002 # Query # # use `test`; INSERT INTO t2 VALUES (NULL, 8)
master-bin.000002 # Query # # COMMIT
master-bin.000002 # Gtid # # BEGIN GTID #-#-#
master-bin.000002 # Intvar # # INSERT_ID=7
master-bin.000002 # Query # # use `test`; INSERT INTO t2 VALUES (NULL, 10)
master-bin.000002 # Query # # COMMIT
master-bin.000002 # Gtid # # BEGIN GTID #-#-#
master-bin.000002 # Intvar # # INSERT_ID=8
master-bin.000002 # Query # # use `test`; INSERT INTO t1 VALUES (NULL, 9)
master-bin.000002 # Intvar # # INSERT_ID=9
master-bin.000002 # Query # # use `test`; INSERT INTO t1 VALUES (NULL, 11)
master-bin.000002 # Query # # ROLLBACK
connection default;
disconnect con1;
disconnect con2;
drop table t1,t2,t3;
end of the tests
|