Commit ee4752c8 authored by Matthias Leich's avatar Matthias Leich

Merge of fix for bug

   41111 events_bugs fails sporadically on pushbuild
into GCA tree
parents 9cef800a f0d1d533
########## include/check_events_off.inc ####################################
# #
# Purpose: #
# Wait till we can expect that we have no event activity till the scheduler is #
# switched on again. #
# = There will be no modifications of user tables by existing events #
# except they use "INSERT DELAYED" or the server system variable #
# "concurrent_inserts" is not switched off. #
# Only some storage engines support concurrent_inserts" or "INSERT DELAYED". #
# #
# Creation: #
# 2008-12-19 mleich Implement this check needed for bug fixes in tests #
# #
################################################################################
# 1. Check that the server system variable shows the state needed
if (`SELECT @@global.event_scheduler <> 'OFF'`)
{
--echo # Error: We expect here that the event scheduler is switched off.
SELECT @@global.event_scheduler;
--echo # Thinkable reasons:
--echo # 1. SET GLOBAL event_scheduler = OFF had not the expected effect.
--echo # 2. Use of the current routine (include/check_events_off.inc)
--echo # within the wrong situation
--die
}
# 2. Wait till we have no event_scheduler session within the processlist
--source include/no_running_event_scheduler.inc
# 3. Wait till we have no event executor sessions within the processlist
--source include/no_running_events.inc
########## include/no_running_event_scheduler.inc ##########################
# #
# Wait till the event scheduler disappeared from processlist. #
# #
# The characteristics of the event_scheduler entry within the processlist is #
# user = 'event_scheduler' and command = 'Daemon'. I am not 100% sure if #
# ther is no short phase with command <> 'Daemon'. #
# A query with WHERE user = 'event_scheduler' only will also catch events in #
# startup phase. This is no problem since this phase is very short. #
# #
# A wait_timeout of >= 3 seconds was within experiments sufficient even on a #
# testing box with heavy parallel load. Therefore 5 seconds should be enough. #
# #
# Creation: #
# 2008-12-19 mleich Implement this check needed for test bug fixes #
# #
################################################################################
let $wait_timeout= 5;
let $wait_condition=
SELECT COUNT(*) = 0 FROM information_schema.processlist
WHERE user = 'event_scheduler';
--source include/wait_condition.inc
########## include/no_running_events.inc ###################################
# #
# Wait till all event executors have finished their work. #
# #
# Different event executors share the characteristics that their entry within #
# processlist contains command = 'Connect'. #
# Of course the corresponding query will also catch other connections being #
# within the connect phase. This is no problem since the connect phase is #
# usually very short. #
# #
# A wait_timeout of >= 3 seconds was during experiments in case of "simple" #
# SQL commands sufficient even on a testing box with heavy parallel load. #
# "simple" = no sleeps, no long running commands, no waiting for lock ... #
# We use here the default of 30 seconds because this wastes some time only in #
# case of unexpected situations. #
# #
# Creation: #
# 2008-12-19 mleich Implement this check needed for test bug fixes #
# #
################################################################################
let $wait_condition=
SELECT COUNT(*) = 0 FROM information_schema.processlist
WHERE command = 'Connect';
--source include/wait_condition.inc
############# include/running_event_scheduler.inc ##########################
# #
# Wait till the event scheduler reached its final state within the processlist.#
# #
# The characteristics of the event_scheduler entry within the processlist is #
# user = 'event_scheduler' and command = 'Daemon'. I am not 100% sure if #
# ther is no short phase with command <> 'Daemon'. #
# A query with WHERE user = 'event_scheduler' only will also catch events in #
# startup phase. #
# #
# Creation: #
# 2008-12-19 mleich Implement this check needed for test bug fixes #
# #
################################################################################
# 1. Check that the server system variable shows the state needed
if (`SELECT @@global.event_scheduler <> 'ON'`)
{
--echo # Error: We expect here that the event scheduler is switched on.
SELECT @@global.event_scheduler;
--echo # Thinkable reasons:
--echo # 1. SET GLOBAL event_scheduler = ON had not the expected effect.
--echo # 2. Use of the current routine (include/running_event_scheduler.inc)
--echo # within the wrong situation
--die
}
let $wait_condition=
SELECT COUNT(*) = 1 FROM information_schema.processlist
WHERE user = 'event_scheduler' AND command = 'Daemon';
--source include/wait_condition.inc
...@@ -3,6 +3,8 @@ drop database if exists mysqltest_db1; ...@@ -3,6 +3,8 @@ drop database if exists mysqltest_db1;
drop database if exists mysqltest_db2; drop database if exists mysqltest_db2;
create database events_test; create database events_test;
use events_test; use events_test;
set @concurrent_insert= @@global.concurrent_insert;
set @@global.concurrent_insert = 0;
select * from information_schema.global_variables where variable_name like 'event_scheduler'; select * from information_schema.global_variables where variable_name like 'event_scheduler';
VARIABLE_NAME VARIABLE_VALUE VARIABLE_NAME VARIABLE_VALUE
EVENT_SCHEDULER ON EVENT_SCHEDULER ON
...@@ -60,7 +62,7 @@ select get_lock('test_bug16407', 60); ...@@ -60,7 +62,7 @@ select get_lock('test_bug16407', 60);
end| end|
"Now if everything is fine the event has compiled and is locked" "Now if everything is fine the event has compiled and is locked"
select /*1*/ user, host, db, info from information_schema.processlist select /*1*/ user, host, db, info from information_schema.processlist
where info = 'select get_lock(\'test_bug16407\', 60)'; where state = 'User lock' and info = 'select get_lock(\'test_bug16407\', 60)';
user host db info user host db info
root localhost events_test select get_lock('test_bug16407', 60) root localhost events_test select get_lock('test_bug16407', 60)
select release_lock('test_bug16407'); select release_lock('test_bug16407');
...@@ -84,7 +86,7 @@ get_lock('ee_16407_2', 60) ...@@ -84,7 +86,7 @@ get_lock('ee_16407_2', 60)
set global event_scheduler= 1; set global event_scheduler= 1;
"Another sql_mode test" "Another sql_mode test"
set sql_mode="traditional"; set sql_mode="traditional";
create table events_smode_test(ev_name char(10), a date) engine=myisam; create table events_smode_test(ev_name char(10), a date);
"This should never insert something" "This should never insert something"
create event ee_16407_2 on schedule every 60 second do create event ee_16407_2 on schedule every 60 second do
begin begin
...@@ -92,7 +94,7 @@ select get_lock('ee_16407_2', 60) /*ee_16407_2*/; ...@@ -92,7 +94,7 @@ select get_lock('ee_16407_2', 60) /*ee_16407_2*/;
select release_lock('ee_16407_2'); select release_lock('ee_16407_2');
insert into events_test.events_smode_test values('ee_16407_2','1980-19-02'); insert into events_test.events_smode_test values('ee_16407_2','1980-19-02');
end| end|
insert into events_smode_test values ('test','1980-19-02')| insert into events_test.events_smode_test values ('test','1980-19-02')|
ERROR 22007: Incorrect date value: '1980-19-02' for column 'a' at row 1 ERROR 22007: Incorrect date value: '1980-19-02' for column 'a' at row 1
"This is ok" "This is ok"
create event ee_16407_3 on schedule every 60 second do create event ee_16407_3 on schedule every 60 second do
...@@ -116,7 +118,7 @@ events_test ee_16407_2 STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ ...@@ -116,7 +118,7 @@ events_test ee_16407_2 STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_
events_test ee_16407_3 STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER events_test ee_16407_3 STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER
events_test ee_16407_4 events_test ee_16407_4
select /*2*/ user, host, db, info from information_schema.processlist select /*2*/ user, host, db, info from information_schema.processlist
where info = 'select get_lock(\'ee_16407_2\', 60)'; where state = 'User lock' and info = 'select get_lock(\'ee_16407_2\', 60)';
user host db info user host db info
root localhost events_test select get_lock('ee_16407_2', 60) root localhost events_test select get_lock('ee_16407_2', 60)
root localhost events_test select get_lock('ee_16407_2', 60) root localhost events_test select get_lock('ee_16407_2', 60)
...@@ -125,10 +127,10 @@ select release_lock('ee_16407_2'); ...@@ -125,10 +127,10 @@ select release_lock('ee_16407_2');
release_lock('ee_16407_2') release_lock('ee_16407_2')
1 1
select /*3*/ user, host, db, info from information_schema.processlist select /*3*/ user, host, db, info from information_schema.processlist
where info = 'select get_lock(\'ee_16407_2\', 60)'; where state = 'User lock' and info = 'select get_lock(\'ee_16407_2\', 60)';
user host db info user host db info
set global event_scheduler= off; set global event_scheduler= off;
select * from events_smode_test order by ev_name, a; select * from events_test.events_smode_test order by ev_name, a;
ev_name a ev_name a
ee_16407_3 1980-02-19 ee_16407_3 1980-02-19
ee_16407_3 1980-02-29 ee_16407_3 1980-02-29
...@@ -143,7 +145,7 @@ drop event ee_16407_2; ...@@ -143,7 +145,7 @@ drop event ee_16407_2;
drop event ee_16407_3; drop event ee_16407_3;
drop event ee_16407_4; drop event ee_16407_4;
"And now one last test regarding sql_mode and call of SP from an event" "And now one last test regarding sql_mode and call of SP from an event"
delete from events_smode_test; delete from events_test.events_smode_test;
set sql_mode='ansi'; set sql_mode='ansi';
select get_lock('ee_16407_5', 60); select get_lock('ee_16407_5', 60);
get_lock('ee_16407_5', 60) get_lock('ee_16407_5', 60)
...@@ -166,10 +168,8 @@ call events_test.ee_16407_6_pendant(); ...@@ -166,10 +168,8 @@ call events_test.ee_16407_6_pendant();
end| end|
"Should have 2 locked processes" "Should have 2 locked processes"
select /*4*/ user, host, db, info from information_schema.processlist select /*4*/ user, host, db, info from information_schema.processlist
where (command!='Daemon' || user='event_scheduler') and (info is null or info not like '%processlist%') where state = 'User lock' and info = 'select get_lock(\'ee_16407_5\', 60)';
order by info;
user host db info user host db info
event_scheduler localhost NULL NULL
root localhost events_test select get_lock('ee_16407_5', 60) root localhost events_test select get_lock('ee_16407_5', 60)
root localhost events_test select get_lock('ee_16407_5', 60) root localhost events_test select get_lock('ee_16407_5', 60)
select release_lock('ee_16407_5'); select release_lock('ee_16407_5');
...@@ -177,11 +177,9 @@ release_lock('ee_16407_5') ...@@ -177,11 +177,9 @@ release_lock('ee_16407_5')
1 1
"Should have 0 processes locked" "Should have 0 processes locked"
select /*5*/ user, host, db, info from information_schema.processlist select /*5*/ user, host, db, info from information_schema.processlist
where (command!='Daemon' || user='event_scheduler') and (info is null or info not like '%processlist%') where state = 'User lock' and info = 'select get_lock(\'ee_16407_5\', 60)';
order by info;
user host db info user host db info
event_scheduler localhost NULL NULL select * from events_test.events_smode_test order by ev_name, a;
select * from events_smode_test order by ev_name, a;
ev_name a ev_name a
ee_16407_6 2004-02-29 ee_16407_6 2004-02-29
"And here we check one more time before we drop the events" "And here we check one more time before we drop the events"
...@@ -740,3 +738,4 @@ name ...@@ -740,3 +738,4 @@ name
drop event e1; drop event e1;
DROP DATABASE events_test; DROP DATABASE events_test;
SET GLOBAL event_scheduler = 'ON'; SET GLOBAL event_scheduler = 'ON';
SET @@global.concurrent_insert = @concurrent_insert;
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment