summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerge Kozlov <Serge.Kozlov@sun.com>2009-01-21 18:48:12 +0300
committerSerge Kozlov <Serge.Kozlov@sun.com>2009-01-21 18:48:12 +0300
commit4562b69fedb26a5095f45dbe0441c952aa09001c (patch)
treec761c265eea18cfb2f88886293c1fc1ee82638da
parent237ef78e1cd978c545b27179fa51cd6ff022210c (diff)
downloadmariadb-git-4562b69fedb26a5095f45dbe0441c952aa09001c.tar.gz
Bug#30128: The reason that sometimes events were executed because without STARTS
clause server fires immediately after creating event and time between create and delete event sometimes is enough for firing. So adding STARTS clause moves first execution in future after drop of event 1. Added STARTS clause for CREATE EVENT. 2. Updated result file.
-rw-r--r--mysql-test/include/rpl_events.inc16
-rw-r--r--mysql-test/suite/rpl/r/rpl_events.result20
-rw-r--r--mysql-test/suite/rpl/t/rpl_events.test6
3 files changed, 27 insertions, 15 deletions
diff --git a/mysql-test/include/rpl_events.inc b/mysql-test/include/rpl_events.inc
index 34ceba81a38..0effa8c4e5c 100644
--- a/mysql-test/include/rpl_events.inc
+++ b/mysql-test/include/rpl_events.inc
@@ -62,7 +62,9 @@ SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name
DROP EVENT IF EXISTS test.slave_once;
--enable_warnings
-CREATE EVENT test.slave_once ON SCHEDULE EVERY 5 MINUTE DO
+# Create an event on slave and check its state. An event shouldn't be executed
+# so set start time in 1 hour.
+CREATE EVENT test.slave_once ON SCHEDULE EVERY 5 MINUTE STARTS CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO
INSERT IGNORE INTO t1(id, c) VALUES (3, 'from slave_once');
--echo "Checking event status on the slave for originator value = slave's server_id"
@@ -81,8 +83,11 @@ connection master;
DROP EVENT IF EXISTS test.justonce;
--enable_warnings
+# Create an event on master and check its state on slave. An event shouldn't be executed
+# so set start time in 1 hour. Check that changes of event statement replicated to slave
+
--echo "Creating event test.er on the master"
-CREATE EVENT test.er ON SCHEDULE EVERY 3 SECOND DO
+CREATE EVENT test.er ON SCHEDULE EVERY 3 SECOND STARTS CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO
INSERT IGNORE INTO t1(id, c) VALUES (4, 'from er');
--echo "Checking event status on the master"
@@ -95,7 +100,7 @@ SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND
connection master;
--echo "Altering event test.er on the master"
-ALTER EVENT test.er ON SCHEDULE EVERY 5 SECOND DO
+ALTER EVENT test.er ON SCHEDULE EVERY 5 SECOND STARTS CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO
INSERT IGNORE INTO t1(id, c) VALUES (5, 'from alter er');
--echo "Checking event status on the master"
@@ -123,8 +128,11 @@ SELECT db, name, status, originator FROM mysql.event WHERE db = 'test';
# test the DISABLE ON SLAVE for setting event SLAVESIDE_DISABLED as status
# on CREATE EVENT
+# Create an event on slave and check its status. An event shouldn't be executed
+# so set start time in 1 hour.
+
--echo "Creating event test.slave_terminate on the slave"
-CREATE EVENT test.slave_terminate ON SCHEDULE EVERY 3 SECOND DO
+CREATE EVENT test.slave_terminate ON SCHEDULE EVERY 3 SECOND STARTS CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO
INSERT IGNORE INTO t1(id, c) VALUES (6, 'from slave_terminate');
--echo "Checking event status on the slave"
diff --git a/mysql-test/suite/rpl/r/rpl_events.result b/mysql-test/suite/rpl/r/rpl_events.result
index e4a412cb1d5..b797183f9d2 100644
--- a/mysql-test/suite/rpl/r/rpl_events.result
+++ b/mysql-test/suite/rpl/r/rpl_events.result
@@ -1,10 +1,11 @@
-set global event_scheduler=1;
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
+SET @old_event_scheduler = @@global.event_scheduler;
+set global event_scheduler=1;
set binlog_format=row;
DROP EVENT IF EXISTS test.justonce;
drop table if exists t1,t2;
@@ -34,7 +35,7 @@ db name status originator
test justonce SLAVESIDE_DISABLED 1
"Dropping event test.slave_once on the slave"
DROP EVENT IF EXISTS test.slave_once;
-CREATE EVENT test.slave_once ON SCHEDULE EVERY 5 MINUTE DO
+CREATE EVENT test.slave_once ON SCHEDULE EVERY 5 MINUTE STARTS CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO
INSERT IGNORE INTO t1(id, c) VALUES (3, 'from slave_once');
"Checking event status on the slave for originator value = slave's server_id"
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'slave_once';
@@ -45,7 +46,7 @@ DROP EVENT IF EXISTS test.slave_once;
"Dropping event test.justonce on the master"
DROP EVENT IF EXISTS test.justonce;
"Creating event test.er on the master"
-CREATE EVENT test.er ON SCHEDULE EVERY 3 SECOND DO
+CREATE EVENT test.er ON SCHEDULE EVERY 3 SECOND STARTS CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO
INSERT IGNORE INTO t1(id, c) VALUES (4, 'from er');
"Checking event status on the master"
SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND name = 'er';
@@ -56,7 +57,7 @@ SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND
db name status originator body
test er SLAVESIDE_DISABLED 1 INSERT IGNORE INTO t1(id, c) VALUES (4, 'from er')
"Altering event test.er on the master"
-ALTER EVENT test.er ON SCHEDULE EVERY 5 SECOND DO
+ALTER EVENT test.er ON SCHEDULE EVERY 5 SECOND STARTS CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO
INSERT IGNORE INTO t1(id, c) VALUES (5, 'from alter er');
"Checking event status on the master"
SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND name = 'er';
@@ -75,7 +76,7 @@ db name status originator
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test';
db name status originator
"Creating event test.slave_terminate on the slave"
-CREATE EVENT test.slave_terminate ON SCHEDULE EVERY 3 SECOND DO
+CREATE EVENT test.slave_terminate ON SCHEDULE EVERY 3 SECOND STARTS CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO
INSERT IGNORE INTO t1(id, c) VALUES (6, 'from slave_terminate');
"Checking event status on the slave"
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'slave_terminate';
@@ -123,7 +124,7 @@ db name status originator
test justonce SLAVESIDE_DISABLED 1
"Dropping event test.slave_once on the slave"
DROP EVENT IF EXISTS test.slave_once;
-CREATE EVENT test.slave_once ON SCHEDULE EVERY 5 MINUTE DO
+CREATE EVENT test.slave_once ON SCHEDULE EVERY 5 MINUTE STARTS CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO
INSERT IGNORE INTO t1(id, c) VALUES (3, 'from slave_once');
"Checking event status on the slave for originator value = slave's server_id"
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'slave_once';
@@ -134,7 +135,7 @@ DROP EVENT IF EXISTS test.slave_once;
"Dropping event test.justonce on the master"
DROP EVENT IF EXISTS test.justonce;
"Creating event test.er on the master"
-CREATE EVENT test.er ON SCHEDULE EVERY 3 SECOND DO
+CREATE EVENT test.er ON SCHEDULE EVERY 3 SECOND STARTS CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO
INSERT IGNORE INTO t1(id, c) VALUES (4, 'from er');
"Checking event status on the master"
SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND name = 'er';
@@ -145,7 +146,7 @@ SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND
db name status originator body
test er SLAVESIDE_DISABLED 1 INSERT IGNORE INTO t1(id, c) VALUES (4, 'from er')
"Altering event test.er on the master"
-ALTER EVENT test.er ON SCHEDULE EVERY 5 SECOND DO
+ALTER EVENT test.er ON SCHEDULE EVERY 5 SECOND STARTS CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO
INSERT IGNORE INTO t1(id, c) VALUES (5, 'from alter er');
"Checking event status on the master"
SELECT db, name, status, originator, body FROM mysql.event WHERE db = 'test' AND name = 'er';
@@ -164,7 +165,7 @@ db name status originator
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test';
db name status originator
"Creating event test.slave_terminate on the slave"
-CREATE EVENT test.slave_terminate ON SCHEDULE EVERY 3 SECOND DO
+CREATE EVENT test.slave_terminate ON SCHEDULE EVERY 3 SECOND STARTS CURRENT_TIMESTAMP + INTERVAL 1 HOUR DO
INSERT IGNORE INTO t1(id, c) VALUES (6, 'from slave_terminate');
"Checking event status on the slave"
SELECT db, name, status, originator FROM mysql.event WHERE db = 'test' AND name = 'slave_terminate';
@@ -190,4 +191,5 @@ select * from t28953;
END;|
ALTER EVENT event1 RENAME TO event2;
DROP EVENT event2;
+SET @@global.event_scheduler= @old_event_scheduler;
DROP TABLE t28953;
diff --git a/mysql-test/suite/rpl/t/rpl_events.test b/mysql-test/suite/rpl/t/rpl_events.test
index 2a9cf86fe55..d06a3118389 100644
--- a/mysql-test/suite/rpl/t/rpl_events.test
+++ b/mysql-test/suite/rpl/t/rpl_events.test
@@ -5,11 +5,12 @@
# in both row based and statement based format #
##################################################################
-set global event_scheduler=1;
-
--source include/not_embedded.inc
--source include/master-slave.inc
+SET @old_event_scheduler = @@global.event_scheduler;
+set global event_scheduler=1;
+
let $engine_type= MyISAM;
set binlog_format=row;
@@ -51,5 +52,6 @@ sync_slave_with_master;
# that there is no bad timing cauing it to try to access the table.
connection master;
+SET @@global.event_scheduler= @old_event_scheduler;
DROP TABLE t28953;
sync_slave_with_master;