2744 Matthias Leich 2008-12-19 [merge]
Merge into actual tree
added:
mysql-test/r/query_cache_28249.result
mysql-test/t/query_cache_28249.test
modified:
mysql-test/r/events_scheduling.result
mysql-test/r/query_cache.result
mysql-test/t/disabled.def
mysql-test/t/events_scheduling.test
mysql-test/t/query_cache.test
2743 Davi Arnaut 2008-12-19 [merge]
Merge before pushing.
added:
mysql-test/r/innodb_bug38231.result
mysql-test/r/innodb_bug39438.result
mysql-test/t/innodb_bug38231.test
mysql-test/t/innodb_bug39438-master.opt
mysql-test/t/innodb_bug39438.test
modified:
mysql-test/lib/mtr_report.pl
mysql-test/r/innodb-autoinc.result
mysql-test/r/innodb.result
mysql-test/suite/binlog/r/binlog_innodb.result
mysql-test/t/innodb-autoinc.test
mysql-test/t/innodb.test
storage/innobase/Makefile.am
storage/innobase/btr/btr0sea.c
storage/innobase/buf/buf0lru.c
storage/innobase/dict/dict0dict.c
storage/innobase/dict/dict0mem.c
storage/innobase/handler/ha_innodb.cc
storage/innobase/handler/ha_innodb.h
storage/innobase/include/btr0sea.h
storage/innobase/include/dict0dict.h
storage/innobase/include/dict0mem.h
storage/innobase/include/ha_prototypes.h
storage/innobase/include/lock0lock.h
storage/innobase/include/row0mysql.h
storage/innobase/include/sync0sync.ic
storage/innobase/include/ut0ut.h
storage/innobase/lock/lock0lock.c
storage/innobase/os/os0file.c
storage/innobase/plug.in
storage/innobase/row/row0mysql.c
storage/innobase/row/row0sel.c
storage/innobase/srv/srv0srv.c
storage/innobase/srv/srv0start.c
storage/innobase/ut/ut0ut.c
=== modified file 'mysql-test/r/events_scheduling.result'
--- a/mysql-test/r/events_scheduling.result 2008-11-21 21:28:23 +0000
+++ b/mysql-test/r/events_scheduling.result 2008-12-16 18:09:09 +0000
@@ -62,18 +62,6 @@ CREATE EVENT event_4 ON SCHEDULE EVERY 1
ON COMPLETION PRESERVE
DO
INSERT INTO table_4 VALUES (1);
-SELECT IF(SUM(a) >= 4, 'OK', 'ERROR') FROM table_1;
-IF(SUM(a) >= 4, 'OK', 'ERROR')
-OK
-SELECT IF(SUM(a) >= 4, 'OK', 'ERROR') FROM table_2;
-IF(SUM(a) >= 4, 'OK', 'ERROR')
-OK
-SELECT IF(SUM(a) >= 1, 'OK', 'ERROR') FROM table_3;
-IF(SUM(a) >= 1, 'OK', 'ERROR')
-OK
-SELECT IF(SUM(a) >= 1, 'OK', 'ERROR') FROM table_4;
-IF(SUM(a) >= 1, 'OK', 'ERROR')
-OK
SELECT IF(TIME_TO_SEC(TIMEDIFF(ENDS,STARTS))=6, 'OK', 'ERROR')
FROM INFORMATION_SCHEMA.EVENTS
WHERE EVENT_SCHEMA=DATABASE() AND EVENT_NAME='event_2';
=== modified file 'mysql-test/r/query_cache.result'
--- a/mysql-test/r/query_cache.result 2008-07-24 13:41:55 +0000
+++ b/mysql-test/r/query_cache.result 2008-11-28 15:45:34 +0000
@@ -1116,12 +1116,13 @@ create procedure `p1`()
begin
select a, f1() from t1;
end//
+SET @log_bin_trust_function_creators = @@global.log_bin_trust_function_creators;
SET GLOBAL log_bin_trust_function_creators = 1;
call p1()//
a f1()
1 2
2 2
-SET GLOBAL log_bin_trust_function_creators = 0;
+SET GLOBAL log_bin_trust_function_creators = @log_bin_trust_function_creators;
drop procedure p1//
drop function f1//
drop table t1//
@@ -1615,41 +1616,6 @@ id
DROP PROCEDURE proc29856;
DROP TABLE t1;
SET GLOBAL query_cache_size= default;
-Bug#28249 Query Cache returns wrong result with concurrent insert/ certain lock
-set GLOBAL query_cache_type=1;
-set GLOBAL query_cache_limit=10000;
-set GLOBAL query_cache_min_res_unit=0;
-set GLOBAL query_cache_size= 100000;
-flush tables;
-drop table if exists t1, t2;
-create table t1 (a int);
-create table t2 (a int);
-insert into t1 values (1),(2),(3);
-Locking table T2 with a write lock.
-lock table t2 write;
-Select blocked by write lock.
-select *, (select count(*) from t2) from t1;;
-Sleeing is ok, because selecting should be done very fast.
-Inserting into table T1.
-insert into t1 values (4);
-Unlocking the tables.
-unlock tables;
-Collecting result from previously blocked select.
-Next select should contain 4 rows, as the insert is long finished.
-select *, (select count(*) from t2) from t1;
-a (select count(*) from t2)
-1 0
-2 0
-3 0
-4 0
-reset query cache;
-select *, (select count(*) from t2) from t1;
-a (select count(*) from t2)
-1 0
-2 0
-3 0
-4 0
-drop table t1,t2;
#
# Bug#25132 disabled query cache: Qcache_free_blocks = 1
#
=== added file 'mysql-test/r/query_cache_28249.result'
--- a/mysql-test/r/query_cache_28249.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/query_cache_28249.result 2008-11-28 15:45:34 +0000
@@ -0,0 +1,62 @@
+SET @query_cache_type= @@global.query_cache_type;
+SET @query_cache_limit= @@global.query_cache_limit;
+SET @query_cache_min_res_unit= @@global.query_cache_min_res_unit;
+SET @query_cache_size= @@global.query_cache_size;
+# Bug#28249 Query Cache returns wrong result with concurrent insert/ certain lock
+# Establish connections user1,user2,user3 (user=root)
+# Switch to connection user1
+SET GLOBAL query_cache_type=1;
+SET GLOBAL query_cache_limit=10000;
+SET GLOBAL query_cache_min_res_unit=0;
+SET GLOBAL query_cache_size= 100000;
+FLUSH TABLES;
+DROP TABLE IF EXISTS t1, t2;
+CREATE TABLE t1 (a INT);
+CREATE TABLE t2 (a INT);
+INSERT INTO t1 VALUES (1),(2),(3);
+# Switch to connection user2
+LOCK TABLE t2 WRITE;
+# Switch to connection user1
+# "send" the next select, "reap" the result later.
+# The select will be blocked by the write lock on the t1.
+SELECT *, (SELECT COUNT(*) FROM t2) FROM t1;
+# Switch to connection user3
+# Poll till the select of connection user1 is blocked by the write lock on t1.
+SELECT user,command,state,info FROM information_schema.processlist
+WHERE state = 'Locked'
+ AND info = 'SELECT *, (SELECT COUNT(*) FROM t2) FROM t1';
+user command state info
+root Query Locked SELECT *, (SELECT COUNT(*) FROM t2) FROM t1
+INSERT INTO t1 VALUES (4);
+# Switch to connection user2
+UNLOCK TABLES;
+# Switch to connection user1
+# Collecting ("reap") the result from the previously blocked select.
+# The printing of the result (varies between 3 and 4 rows) set has to be suppressed.
+# Switch to connection user3
+# The next select enforces that effects of "concurrent_inserts" like the
+# record with a = 4 is missing in result sets can no more happen.
+SELECT 1 FROM t1 WHERE a = 4;
+1
+1
+# Switch to connection user1
+# The next result set must contain 4 rows.
+SELECT *, (SELECT COUNT(*) FROM t2) FROM t1;
+a (SELECT COUNT(*) FROM t2)
+1 0
+2 0
+3 0
+4 0
+RESET QUERY CACHE;
+SELECT *, (SELECT COUNT(*) FROM t2) FROM t1;
+a (SELECT COUNT(*) FROM t2)
+1 0
+2 0
+3 0
+4 0
+DROP TABLE t1,t2;
+# Switch to connection default + close connections user1,user2,user3
+SET GLOBAL query_cache_type= @query_cache_type;
+SET GLOBAL query_cache_limit= @query_cache_limit;
+SET GLOBAL query_cache_min_res_unit= @query_cache_min_res_unit;
+SET GLOBAL query_cache_size= @query_cache_size;
=== modified file 'mysql-test/t/disabled.def'
--- a/mysql-test/t/disabled.def 2008-12-09 16:34:31 +0000
+++ b/mysql-test/t/disabled.def 2008-12-18 18:28:44 +0000
@@ -12,4 +12,5 @@
federated_transactions : Bug#29523 Transactions do not work
slow_query_log_func : Bug #37962: *_func tests containing sleeps/race conditions
wait_timeout_func : Bug #41225 joro wait_timeout_func fails
-kill : Bug#37780 2008-12-03 HHunger need some changes to be robust enoiugh for pushbuild.
+kill : Bug#37780 2008-12-03 HHunger need some changes to be robust enough for pushbuild.
+query_cache_28249 : Bug#41098 Query Cache returns wrong result with concurrent insert
=== modified file 'mysql-test/t/events_scheduling.test'
--- a/mysql-test/t/events_scheduling.test 2008-11-21 21:28:23 +0000
+++ b/mysql-test/t/events_scheduling.test 2008-12-16 18:09:09 +0000
@@ -58,8 +58,6 @@ ON COMPLETION PRESERVE
DO
INSERT INTO table_4 VALUES (1);
-# Wait for the events to fire and check the data afterwards
-
# Let event_1 insert at least 4 records into the table
let $wait_condition=select count(*) >= 4 from table_1;
--source include/wait_condition.inc
@@ -85,25 +83,13 @@ let $wait_condition=select count(*) = 0
where event_name='event_4' and status='enabled';
--source include/wait_condition.inc
-let $wait_condition=SELECT SUM(a) >= 4 FROM table_1;
-source include/wait_condition.inc;
-SELECT IF(SUM(a) >= 4, 'OK', 'ERROR') FROM table_1;
-
-# In case of a testing box under heavy load it cannot be guaranteed that
-# it is really often enough checked if event_2 has to be executed.
-# -> Bug#39854 events_scheduling fails sporadically on pushbuild
-# Therefore we lowered here the original expectation of 5 to 4.
-let $wait_condition=SELECT SUM(a) >= 4 FROM table_2;
-source include/wait_condition.inc;
-SELECT IF(SUM(a) >= 4, 'OK', 'ERROR') FROM table_2;
-
-let $wait_condition=SELECT SUM(a) >= 1 FROM table_3;
-source include/wait_condition.inc;
-SELECT IF(SUM(a) >= 1, 'OK', 'ERROR') FROM table_3;
-
-let $wait_condition=SELECT SUM(a) >= 1 FROM table_4;
-source include/wait_condition.inc;
-SELECT IF(SUM(a) >= 1, 'OK', 'ERROR') FROM table_4;
+#
+# On a busy system the scheduler may skip execution of events,
+# we can't reliably expect that the data in a table to be modified
+# by an event will be exact. Thus we do not SELECT from the tables
+# in this test. See also
+# Bug#39854 events_scheduling fails sporadically on pushbuild
+#
SELECT IF(TIME_TO_SEC(TIMEDIFF(ENDS,STARTS))=6, 'OK', 'ERROR')
FROM INFORMATION_SCHEMA.EVENTS
=== modified file 'mysql-test/t/query_cache.test'
--- a/mysql-test/t/query_cache.test 2008-03-26 16:36:12 +0000
+++ b/mysql-test/t/query_cache.test 2008-12-18 18:28:44 +0000
@@ -300,7 +300,7 @@ select * from t1;
select * from t1;
show status like "Qcache_queries_in_cache";
insert delayed into t1 values (4);
---sleep 5 # Wait for insert delayed to be executed.
+--sleep 5 # Wait for insert delayed to be executed.
select a from t1;
show status like "Qcache_queries_in_cache";
drop table t1;
@@ -410,10 +410,10 @@ create table t1(id int auto_increment pr
insert into t1 values (NULL), (NULL), (NULL);
select * from t1 where id=2;
alter table t1 rename to t2;
--- error 1146
+--error ER_NO_SUCH_TABLE
select * from t1 where id=2;
drop table t2;
--- error 1146
+--error ER_NO_SUCH_TABLE
select * from t1 where id=2;
#
@@ -435,11 +435,14 @@ create table t1 (a int);
insert into t1 values (1),(2),(3);
show status like "Qcache_queries_in_cache";
select * from t1 into outfile "query_cache.out.file";
---error 1086
+--error ER_FILE_EXISTS_ERROR
select * from t1 into outfile "query_cache.out.file";
select * from t1 limit 1 into dumpfile "query_cache.dump.file";
show status like "Qcache_queries_in_cache";
drop table t1;
+let $datadir=`select @@datadir`;
+--remove_file $datadir/test/query_cache.dump.file
+--remove_file $datadir/test/query_cache.out.file
#
# test of SQL_SELECT_LIMIT
@@ -537,7 +540,7 @@ drop table t1;
# If at least one of the above variables has changed,
# the cached query can't be reused. In the below test
# absolutely the same query is used several times,
-# SELECT should fetch different results for every instance.
+# SELECT should fetch different results for every instance.
# No hits should be produced.
# New cache entry should appear for every SELECT.
#
@@ -554,21 +557,21 @@ show status like "Qcache_queries_in_cach
# Change collation_connection and run the same query again
#
set collation_connection=koi8r_bin;
-SELECT a,'�,'�'� FROM t1;
+SELECT a,'�,'�'� FROM t1;
show status like "Qcache_hits";
show status like "Qcache_queries_in_cache";
#
# Now change character_set_client and run the same query again
#
set character_set_client=cp1251;
-SELECT a,'�,'�'� FROM t1;
+SELECT a,'�,'�'� FROM t1;
show status like "Qcache_hits";
show status like "Qcache_queries_in_cache";
#
# And finally change character_set_results and run the same query again
#
set character_set_results=cp1251;
-SELECT a,'�,'�'� FROM t1;
+SELECT a,'�,'�'� FROM t1;
show status like "Qcache_hits";
show status like "Qcache_queries_in_cache";
SET NAMES default;
@@ -602,12 +605,12 @@ insert into t1 set c = repeat('x',24);
insert into t1 set c = concat(repeat('x',24),'x');
insert into t1 set c = concat(repeat('x',24),'w');
insert into t1 set c = concat(repeat('x',24),'y');
-set max_sort_length=200;
+set max_sort_length=200;
select c from t1 order by c, id;
reset query cache;
set max_sort_length=20;
select c from t1 order by c, id;
-set max_sort_length=200;
+set max_sort_length=200;
select c from t1 order by c, id;
set max_sort_length=default;
# sql_mode
@@ -801,9 +804,10 @@ create procedure `p1`()
begin
select a, f1() from t1;
end//
+SET @log_bin_trust_function_creators = @@global.log_bin_trust_function_creators;
SET GLOBAL log_bin_trust_function_creators = 1;
call p1()//
-SET GLOBAL log_bin_trust_function_creators = 0;
+SET GLOBAL log_bin_trust_function_creators = @log_bin_trust_function_creators;
drop procedure p1//
drop function f1//
@@ -1016,7 +1020,7 @@ set GLOBAL query_cache_size= default;
#
-# Bug #28897 UUID() returns non-unique values when query cache is enabled
+# Bug#28897 UUID() returns non-unique values when query cache is enabled
#
set GLOBAL query_cache_size=1000000;
@@ -1025,7 +1029,7 @@ create table t1 (a char);
insert into t1 values ('c');
let $q1= `select UUID(), a from t1`;
-let $q2= `select UUID(), a from t1`;
+let $q2= `select UUID(), a from t1`;
# disabling the logging of the query because the UUIDs are different each run.
--disable_query_log
@@ -1046,7 +1050,7 @@ create table t1 (a char);
insert into t1 values ('c');
let $q1= `select RAND() from t1 union select sql_cache 1 from t1;`;
-let $q2= `select RAND() from t1 union select sql_cache 1 from t1;`;
+let $q2= `select RAND() from t1 union select sql_cache 1 from t1;`;
# disabling the logging of the query because the times are different each run.
--disable_query_log
@@ -1182,75 +1186,6 @@ DROP TABLE t1;
SET GLOBAL query_cache_size= default;
#
-# Bug #28249 Query Cache returns wrong result with concurrent insert / certain lock
-#
---echo Bug#28249 Query Cache returns wrong result with concurrent insert/ certain lock
-connect (user1,localhost,root,,test,,);
-connect (user2,localhost,root,,test,,);
-connect (user3,localhost,root,,test,,);
-
-connection user1;
-
-set GLOBAL query_cache_type=1;
-set GLOBAL query_cache_limit=10000;
-set GLOBAL query_cache_min_res_unit=0;
-set GLOBAL query_cache_size= 100000;
-
-flush tables;
---disable_warnings
-drop table if exists t1, t2;
---enable_warnings
-create table t1 (a int);
-create table t2 (a int);
-insert into t1 values (1),(2),(3);
-connection user2;
---echo Locking table T2 with a write lock.
-lock table t2 write;
-
-connection user1;
---echo Select blocked by write lock.
---send select *, (select count(*) from t2) from t1;
---echo Sleeing is ok, because selecting should be done very fast.
-sleep 5;
-
-connection user3;
---echo Inserting into table T1.
-insert into t1 values (4);
-
-connection user2;
---echo Unlocking the tables.
-unlock tables;
-
-connection user1;
---echo Collecting result from previously blocked select.
-#
-# Since the lock ordering rule in thr_multi_lock depends on
-# pointer values, from execution to execution we might have
-# different lock order, and therefore, sometimes lock t1 and block
-# on t2, and sometimes block on t2 right away. In the second case,
-# the following insert succeeds, and only then this select can
-# proceed, and we actually test nothing, as the very first select
-# returns 4 rows right away.
-# It's fine to have a test case that covers the problematic area
-# at least once in a while.
-# We, however, need to disable the result log here to make the
-# test repeatable.
---disable_result_log
---reap
---enable_result_log
---echo Next select should contain 4 rows, as the insert is long finished.
-select *, (select count(*) from t2) from t1;
-reset query cache;
-select *, (select count(*) from t2) from t1;
-
-drop table t1,t2;
-
-connection default;
-disconnect user1;
-disconnect user2;
-disconnect user3;
-
-#
--echo #
--echo # Bug#25132 disabled query cache: Qcache_free_blocks = 1
--echo #
@@ -1260,7 +1195,7 @@ set global query_cache_type=0;
show status like 'Qcache_free_blocks';
--echo Restore default values.
-# Bug #28211 RENAME DATABASE and query cache don't play nicely together
+# Bug#28211 RENAME DATABASE and query cache don't play nicely together
#
# TODO: enable these tests when RENAME DATABASE is implemented.
# --disable_warnings
@@ -1278,7 +1213,7 @@ show status like 'Qcache_free_blocks';
# show status like 'Qcache_queries_in_cache';
# drop database db2;
# set global query_cache_size=default;
-#
+#
# --disable_warnings
# drop database if exists db1;
# drop database if exists db3;
=== added file 'mysql-test/t/query_cache_28249.test'
--- a/mysql-test/t/query_cache_28249.test 1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/query_cache_28249.test 2008-12-18 18:28:44 +0000
@@ -0,0 +1,123 @@
+### t/query_cache_28249.test ###
+#
+# Test for
+# Bug#28249 Query Cache returns wrong result with concurrent insert / certain lock
+#
+# Last modification:
+# 2008-11-27 mleich - Move this test out of query_cache.test
+# - Fix Bug#40179 Test main.query_cache failing randomly on Pushbuild,
+# test weakness
+# - Minor improvements (comments,formatting etc.)
+#
+
+--source include/have_query_cache.inc
+
+SET @query_cache_type= @@global.query_cache_type;
+SET @query_cache_limit= @@global.query_cache_limit;
+SET @query_cache_min_res_unit= @@global.query_cache_min_res_unit;
+SET @query_cache_size= @@global.query_cache_size;
+
+--echo # Bug#28249 Query Cache returns wrong result with concurrent insert/ certain lock
+--echo # Establish connections user1,user2,user3 (user=root)
+connect (user1,localhost,root,,test,,);
+connect (user2,localhost,root,,test,,);
+connect (user3,localhost,root,,test,,);
+
+--echo # Switch to connection user1
+connection user1;
+
+SET GLOBAL query_cache_type=1;
+SET GLOBAL query_cache_limit=10000;
+SET GLOBAL query_cache_min_res_unit=0;
+SET GLOBAL query_cache_size= 100000;
+
+FLUSH TABLES;
+--disable_warnings
+DROP TABLE IF EXISTS t1, t2;
+--enable_warnings
+CREATE TABLE t1 (a INT);
+CREATE TABLE t2 (a INT);
+INSERT INTO t1 VALUES (1),(2),(3);
+
+--echo # Switch to connection user2
+connection user2;
+LOCK TABLE t2 WRITE;
+
+--echo # Switch to connection user1
+connection user1;
+--echo # "send" the next select, "reap" the result later.
+--echo # The select will be blocked by the write lock on the t1.
+let $select_for_qc =
+SELECT *, (SELECT COUNT(*) FROM t2) FROM t1;
+send;
+eval $select_for_qc;
+
+--echo # Switch to connection user3
+connection user3;
+# Typical information_schema.processlist content after sufficient sleep time
+# ID USER COMMAND TIME STATE INFO
+# ....
+# 2 root Query 5 Locked SELECT *, (SELECT COUNT(*) FROM t2) FROM t1
+# ....
+# XXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+# The values marked with 'X' must be reached.
+--echo # Poll till the select of connection user1 is blocked by the write lock on t1.
+let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist
+WHERE state = 'Locked'
+ AND info = '$select_for_qc';
+--source include/wait_condition.inc
+eval
+SELECT user,command,state,info FROM information_schema.processlist
+WHERE state = 'Locked'
+ AND info = '$select_for_qc';
+INSERT INTO t1 VALUES (4);
+
+--echo # Switch to connection user2
+connection user2;
+UNLOCK TABLES;
+
+--echo # Switch to connection user1
+connection user1;
+#
+# Since the lock ordering rule in thr_multi_lock depends on
+# pointer values, from execution to execution we might have
+# different lock order, and therefore, sometimes lock t1 and block
+# on t2, and sometimes block on t2 right away. In the second case,
+# the following insert succeeds, and only then this select can
+# proceed, and we actually test nothing, as the very first select
+# returns 4 rows right away.
+# It's fine to have a test case that covers the problematic area
+# at least once in a while.
+--echo # Collecting ("reap") the result from the previously blocked select.
+--echo # The printing of the result (varies between 3 and 4 rows) set has to be suppressed.
+--disable_result_log
+--reap
+--enable_result_log
+
+--echo # Switch to connection user3
+connection user3;
+--echo # The next select enforces that effects of "concurrent_inserts" like the
+--echo # record with a = 4 is missing in result sets can no more happen.
+SELECT 1 FROM t1 WHERE a = 4;
+
+--echo # Switch to connection user1
+connection user1;
+--echo # The next result set must contain 4 rows.
+# If not, we have a regression of Bug#28249
+eval $select_for_qc;
+RESET QUERY CACHE;
+eval $select_for_qc;
+
+DROP TABLE t1,t2;
+
+--echo # Switch to connection default + close connections user1,user2,user3
+connection default;
+disconnect user1;
+disconnect user2;
+disconnect user3;
+
+SET GLOBAL query_cache_type= @query_cache_type;
+SET GLOBAL query_cache_limit= @query_cache_limit;
+SET GLOBAL query_cache_min_res_unit= @query_cache_min_res_unit;
+SET GLOBAL query_cache_size= @query_cache_size;
+
| Thread |
|---|
| • bzr push into mysql-5.1-bugteam branch (Matthias.Leich:2743 to 2744) | Matthias Leich | 19 Dec |