Skip to content

Commit c964c0b

Browse files
author
davi@mysql.com/endora.local
committed
Bug#34891 sp_notembedded.test fails sporadically
The problem is that since MyISAM's concurrent_insert is on by default some concurrent SELECT statements might not see changes made by INSERT statements in other connections, even if the INSERT statement has returned. The solution is to disable concurrent_insert so that INSERT statements returns after the data is actually visible to other statements.
1 parent 34d9dfb commit c964c0b

6 files changed

+122
-71
lines changed

mysql-test/r/flush_read_lock_kill.result

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
set @old_concurrent_insert= @@global.concurrent_insert;
12
set @@global.concurrent_insert= 0;
23
drop table if exists t1;
34
create table t1 (kill_id int);
@@ -8,3 +9,4 @@ select ((@id := kill_id) - kill_id) from t1;
89
0
910
kill connection @id;
1011
drop table t1;
12+
set @@global.concurrent_insert= @old_concurrent_insert;

mysql-test/r/kill.result

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
set @old_concurrent_insert= @@global.concurrent_insert;
12
set @@global.concurrent_insert= 0;
23
drop table if exists t1, t2, t3;
34
create table t1 (kill_id int);
@@ -137,3 +138,4 @@ KILL CONNECTION_ID();
137138
# of close of the connection socket
138139
SELECT 1;
139140
Got one of the listed errors
141+
set @@global.concurrent_insert= @old_concurrent_insert;

mysql-test/r/sp_notembedded.result

+31-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
set @old_concurrent_insert= @@global.concurrent_insert;
2+
set @@global.concurrent_insert= 0;
13
drop table if exists t1,t3;
24
drop procedure if exists bug4902|
35
create procedure bug4902()
@@ -17,11 +19,11 @@ begin
1719
show processlist;
1820
end|
1921
call bug4902_2()|
20-
Id User Host db Command Time State Info
21-
# root localhost test Query # NULL show processlist
22+
show warnings|
23+
Level Code Message
2224
call bug4902_2()|
23-
Id User Host db Command Time State Info
24-
# root localhost test Query # NULL show processlist
25+
show warnings|
26+
Level Code Message
2527
drop procedure bug4902_2|
2628
drop table if exists t1|
2729
create table t1 (
@@ -68,7 +70,7 @@ c
6870
2
6971
show status like 'Qcache_hits'|
7072
Variable_name Value
71-
Qcache_hits 2
73+
Qcache_hits 0
7274
set global query_cache_size = @x|
7375
flush status|
7476
flush query cache|
@@ -208,3 +210,27 @@ GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION
208210
drop user mysqltest_1@localhost;
209211
drop procedure 15298_1;
210212
drop procedure 15298_2;
213+
drop table if exists t1;
214+
drop procedure if exists p1;
215+
create table t1 (value varchar(15));
216+
create procedure p1() update t1 set value='updated' where value='old';
217+
call p1();
218+
insert into t1 (value) values ("old");
219+
select get_lock('b26162',120);
220+
get_lock('b26162',120)
221+
1
222+
select 'rl_acquirer', value from t1 where get_lock('b26162',120);;
223+
set session low_priority_updates=on;
224+
call p1();;
225+
select 'rl_contender', value from t1;
226+
rl_contender value
227+
rl_contender old
228+
select release_lock('b26162');
229+
release_lock('b26162')
230+
1
231+
rl_acquirer value
232+
rl_acquirer old
233+
drop procedure p1;
234+
drop table t1;
235+
set session low_priority_updates=default;
236+
set @@global.concurrent_insert= @old_concurrent_insert;

mysql-test/t/flush_read_lock_kill.test

+5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
# Disable concurrent inserts to avoid test failures when reading the
1616
# connection id which was inserted into a table by another thread.
17+
set @old_concurrent_insert= @@global.concurrent_insert;
1718
set @@global.concurrent_insert= 0;
1819

1920
connect (con1,localhost,root,,);
@@ -58,3 +59,7 @@ reap;
5859

5960
connection con2;
6061
drop table t1;
62+
connection default;
63+
64+
# Restore global concurrent_insert value
65+
set @@global.concurrent_insert= @old_concurrent_insert;

mysql-test/t/kill.test

+7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
# Disable concurrent inserts to avoid test failures when reading the
1010
# connection id which was inserted into a table by another thread.
11+
set @old_concurrent_insert= @@global.concurrent_insert;
1112
set @@global.concurrent_insert= 0;
1213

1314
connect (con1, localhost, root,,);
@@ -326,3 +327,9 @@ KILL CONNECTION_ID();
326327
--echo # of close of the connection socket
327328
--error 2013, 2006
328329
SELECT 1;
330+
--connection default
331+
332+
###########################################################################
333+
334+
# Restore global concurrent_insert value. Keep in the end of the test file.
335+
set @@global.concurrent_insert= @old_concurrent_insert;

mysql-test/t/sp_notembedded.test

+75-66
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Can't test with embedded server
22
-- source include/not_embedded.inc
3+
# Disable concurrent inserts to avoid test failures
4+
set @old_concurrent_insert= @@global.concurrent_insert;
5+
set @@global.concurrent_insert= 0;
36

4-
--sleep 2
57
--disable_warnings
68
drop table if exists t1,t3;
79
--enable_warnings
@@ -39,10 +41,14 @@ create procedure bug4902_2()
3941
begin
4042
show processlist;
4143
end|
42-
--replace_column 1 # 6 # 3 localhost
44+
--disable_result_log
4345
call bug4902_2()|
44-
--replace_column 1 # 6 # 3 localhost
46+
--enable_result_log
47+
show warnings|
48+
--disable_result_log
4549
call bug4902_2()|
50+
--enable_result_log
51+
show warnings|
4652
drop procedure bug4902_2|
4753

4854
#
@@ -268,69 +274,72 @@ drop procedure 15298_1;
268274
drop procedure 15298_2;
269275

270276
#
271-
# Test case disabled due to Bug#34891: sp_notembedded.test fails sporadically.
277+
# Bug#29936 Stored Procedure DML ignores low_priority_updates setting
272278
#
273-
# #
274-
# # Bug#29936 Stored Procedure DML ignores low_priority_updates setting
275-
# #
276-
#
277-
# --disable_warnings
278-
# drop table if exists t1;
279-
# drop procedure if exists p1;
280-
# --enable_warnings
281-
#
282-
# create table t1 (value varchar(15));
283-
# create procedure p1() update t1 set value='updated' where value='old';
284-
#
285-
# # load the procedure into sp cache and execute once
286-
# call p1();
287-
#
288-
# insert into t1 (value) values ("old");
289-
#
290-
# connect (rl_holder, localhost, root,,);
291-
# connect (rl_acquirer, localhost, root,,);
292-
# connect (rl_contender, localhost, root,,);
293-
# connect (rl_wait, localhost, root,,);
294-
#
295-
# connection rl_holder;
296-
# select get_lock('b26162',120);
297-
#
298-
# connection rl_acquirer;
299-
# --send select 'rl_acquirer', value from t1 where get_lock('b26162',120);
300-
#
301-
# # we must wait till this select opens and locks the tables
302-
# connection rl_wait;
303-
# let $wait_condition=
304-
# select count(*) = 1 from information_schema.processlist
305-
# where state = "User lock" and
306-
# info = "select 'rl_acquirer', value from t1 where get_lock('b26162',120)";
307-
# --source include/wait_condition.inc
308-
#
309-
# connection default;
310-
# set session low_priority_updates=on;
311-
# --send call p1();
312-
#
313-
# connection rl_wait;
314-
# let $wait_condition=
315-
# select count(*) = 1 from information_schema.processlist
316-
# where state = "Locked" and
317-
# info = "update t1 set value='updated' where value='old'";
318-
# --source include/wait_condition.inc
319-
#
320-
# connection rl_contender;
321-
# select 'rl_contender', value from t1;
322-
#
323-
# connection rl_holder;
324-
# select release_lock('b26162');
279+
280+
--disable_warnings
281+
drop table if exists t1;
282+
drop procedure if exists p1;
283+
--enable_warnings
284+
285+
create table t1 (value varchar(15));
286+
create procedure p1() update t1 set value='updated' where value='old';
287+
288+
# load the procedure into sp cache and execute once
289+
call p1();
290+
291+
insert into t1 (value) values ("old");
292+
293+
connect (rl_holder, localhost, root,,);
294+
connect (rl_acquirer, localhost, root,,);
295+
connect (rl_contender, localhost, root,,);
296+
connect (rl_wait, localhost, root,,);
297+
298+
connection rl_holder;
299+
select get_lock('b26162',120);
300+
301+
connection rl_acquirer;
302+
--send select 'rl_acquirer', value from t1 where get_lock('b26162',120);
303+
304+
# we must wait till this select opens and locks the tables
305+
connection rl_wait;
306+
let $wait_condition=
307+
select count(*) = 1 from information_schema.processlist
308+
where state = "User lock" and
309+
info = "select 'rl_acquirer', value from t1 where get_lock('b26162',120)";
310+
--source include/wait_condition.inc
311+
312+
connection default;
313+
set session low_priority_updates=on;
314+
--send call p1();
315+
316+
connection rl_wait;
317+
let $wait_condition=
318+
select count(*) = 1 from information_schema.processlist
319+
where state = "Locked" and
320+
info = "update t1 set value='updated' where value='old'";
321+
--source include/wait_condition.inc
322+
323+
connection rl_contender;
324+
select 'rl_contender', value from t1;
325+
326+
connection rl_holder;
327+
select release_lock('b26162');
328+
329+
connection rl_acquirer;
330+
--reap
331+
connection default;
332+
--reap
333+
334+
disconnect rl_holder;
335+
disconnect rl_acquirer;
336+
disconnect rl_wait;
337+
drop procedure p1;
338+
drop table t1;
339+
set session low_priority_updates=default;
340+
325341
#
326-
# connection rl_acquirer;
327-
# --reap
328-
# connection default;
329-
# --reap
342+
# Restore global concurrent_insert value. Keep in the end of the test file.
330343
#
331-
# disconnect rl_holder;
332-
# disconnect rl_acquirer;
333-
# disconnect rl_wait;
334-
# drop procedure p1;
335-
# drop table t1;
336-
# set session low_priority_updates=default;
344+
345+
set @@global.concurrent_insert= @old_concurrent_insert;

0 commit comments

Comments
 (0)