Skip to content

Commit e3d0524

Browse files
author
andrey@lmy004.
committed
WL#3337 (Event scheduler new architecture)
This patch introduces specialized Event data objects Event_basic as parent. Event_queue_element used for queue storage Event_timed used for SHOW EVENTS/ I_S.EVENTS / SHOW CREATE EVENT Event_job_data using during execution. Methods were moved out of Event_timed to other classes. This patch also introduces Events::LOCK_event_metadata. This patch gives new implementation of Events::dump_internal_status(). Now both the Event_scheduler and Event_queue return information during their ::dump_internal_status(). Shortened a bit the runtime for executing events test cases.
1 parent 3b840ad commit e3d0524

21 files changed

Lines changed: 1852 additions & 1249 deletions

mysql-test/r/events.result

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ events_test event_starts_test root@localhost RECURRING NULL 20 SECOND # # ENABLE
8787
DROP EVENT event_starts_test;
8888
create table test_nested(a int);
8989
create event e_43 on schedule every 1 second do set @a = 5;
90-
set global event_scheduler = 1;
9190
alter event e_43 do alter event e_43 do set @a = 4;
9291
ERROR HY000: Recursivity of EVENT DDL statements is forbidden when body is present
9392
alter event e_43 do
@@ -207,6 +206,10 @@ ERROR 42000: This version of MySQL doesn't yet support 'MICROSECOND'
207206
SHOW EVENTS;
208207
ERROR 42000: This version of MySQL doesn't yet support 'MICROSECOND'
209208
drop event root22;
209+
create event root23 on schedule every -100 year do select 1;
210+
ERROR HY000: INTERVAL is either not positive or too big
211+
create event root23 on schedule every 222222222222222222222 year do select 1;
212+
ERROR HY000: INTERVAL is either not positive or too big
210213
drop event root6;
211214
drop event root7;
212215
drop event root8;
@@ -342,7 +345,7 @@ create event закачка on schedule every 10 hour do select get_lock("test_l
342345
"Should have only 2 processes: the scheduler and the locked event"
343346
select /*2*/ user, host, db, command, state, info from information_schema.processlist where info is null or info not like '%processlist%' order by info;
344347
user host db command state info
345-
event_scheduler localhost NULL Connect Waiting for next activation NULL
348+
event_scheduler localhost NULL Daemon Waiting for next activation NULL
346349
root localhost events_test Connect User lock select get_lock("test_lock2", 20)
347350
"Release the mutex, the event worker should finish."
348351
"Release the mutex, the event worker should finish."
@@ -358,7 +361,7 @@ create event закачка21 on schedule every 10 hour do select get_lock("test
358361
"Should have only 3 processes: the scheduler, our conn and the locked event"
359362
select /*3*/ user, host, db, command, state, info from information_schema.processlist where info is null or info not like '%processlist%' order by info;
360363
user host db command state info
361-
event_scheduler localhost NULL Connect Waiting for next activation NULL
364+
event_scheduler localhost NULL Daemon Waiting for next activation NULL
362365
root localhost events_test Connect User lock select get_lock("test_lock2_1", 20)
363366
set global event_scheduler=2;
364367
"Should have only our process now:"

mysql-test/r/events_bugs.result

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,19 @@ create event e_55 on schedule every 10 hour starts 99990101000000 do drop table
2424
ERROR HY000: Incorrect STARTS value: '99990101000000'
2525
create event e_55 on schedule every 10 minute ends 99990101000000 do drop table t;
2626
ERROR HY000: ENDS is either invalid or before STARTS
27+
create event e_55 on schedule at 10000101000000 do drop table t;
28+
ERROR HY000: Activation (AT) time is in the past
29+
create event e_55 on schedule at 20000101000000 do drop table t;
30+
ERROR HY000: Activation (AT) time is in the past
31+
create event e_55 on schedule at 20200101000000 starts 10000101000000 do drop table t;
32+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'starts 10000101000000 do drop table t' at line 1
33+
create event e_55 on schedule at 20200101000000 ends 10000101000000 do drop table t;
34+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ends 10000101000000 do drop table t' at line 1
35+
create event e_55 on schedule at 20200101000000 starts 10000101000000 ends 10000101000000 do drop table t;
36+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'starts 10000101000000 ends 10000101000000 do drop table t' at line 1
37+
create event e_55 on schedule every 10 hour starts 10000101000000 do drop table t;
38+
ERROR HY000: Incorrect STARTS value: '10000101000000'
2739
set global event_scheduler=2;
28-
"Wait a bit to settle down"
2940
delete from mysql.event;
3041
set global event_scheduler= 1;
3142
set @old_sql_mode:=@@sql_mode;
@@ -41,7 +52,7 @@ end|
4152
"Now if everything is fine the event has compiled and is locked
4253
select /*1*/ user, host, db, command, state, info from information_schema.processlist where info is null or info not like '%processlist%' order by info;
4354
user host db command state info
44-
event_scheduler localhost NULL Connect Waiting for next activation NULL
55+
event_scheduler localhost NULL Daemon Waiting for next activation NULL
4556
root localhost events_test Connect User lock select get_lock('test_bug16407', 60)
4657
select release_lock('test_bug16407');
4758
release_lock('test_bug16407')
@@ -57,13 +68,19 @@ select event_schema, event_name, sql_mode from information_schema.events order b
5768
event_schema event_name sql_mode
5869
events_test e_16407 STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER
5970
drop event e_16407;
71+
set sql_mode="ansi";
72+
select get_lock('ee_16407_2', 60);
73+
get_lock('ee_16407_2', 60)
74+
1
75+
set global event_scheduler= 1;
6076
"Another sql_mode test"
6177
set sql_mode="traditional";
6278
create table events_smode_test(ev_name char(10), a date) engine=myisam;
6379
"This should never insert something"
6480
create event ee_16407_2 on schedule every 60 second do
6581
begin
6682
select get_lock('ee_16407_2', 60) /*ee_16407_2*/;
83+
select release_lock('ee_16407_2');
6784
insert into events_test.events_smode_test values('ee_16407_2','1980-19-02');
6885
end|
6986
insert into events_smode_test values ('test','1980-19-02')|
@@ -72,6 +89,7 @@ ERROR 22007: Incorrect date value: '1980-19-02' for column 'a' at row 1
7289
create event ee_16407_3 on schedule every 60 second do
7390
begin
7491
select get_lock('ee_16407_2', 60) /*ee_16407_3*/;
92+
select release_lock('ee_16407_2');
7593
insert into events_test.events_smode_test values ('ee_16407_3','1980-02-19');
7694
insert into events_test.events_smode_test values ('ee_16407_3','1980-02-29');
7795
end|
@@ -80,21 +98,17 @@ set sql_mode=""|
8098
create event ee_16407_4 on schedule every 60 second do
8199
begin
82100
select get_lock('ee_16407_2', 60) /*ee_16407_4*/;
101+
select release_lock('ee_16407_2');
83102
insert into events_test.events_smode_test values ('ee_16407_4','10-11-1956');
84103
end|
85104
select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name;
86105
event_schema event_name sql_mode
87106
events_test ee_16407_2 STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER
88107
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
89108
events_test ee_16407_4
90-
set sql_mode="ansi";
91-
select get_lock('ee_16407_2', 60);
92-
get_lock('ee_16407_2', 60)
93-
1
94-
set global event_scheduler= 1;
95109
select /*2*/ user, host, db, command, state, info from information_schema.processlist where info is null or info not like '%processlist%' order by info;
96110
user host db command state info
97-
event_scheduler localhost NULL Connect Waiting for next activation NULL
111+
event_scheduler localhost NULL Daemon Waiting for next activation NULL
98112
root localhost events_test Connect User lock select get_lock('ee_16407_2', 60) /*ee_16407_2*/
99113
root localhost events_test Connect User lock select get_lock('ee_16407_2', 60) /*ee_16407_3*/
100114
root localhost events_test Connect User lock select get_lock('ee_16407_2', 60) /*ee_16407_4*/
@@ -103,7 +117,7 @@ release_lock('ee_16407_2')
103117
1
104118
select /*3*/ user, host, db, command, state, info from information_schema.processlist where info is null or info not like '%processlist%' order by info;
105119
user host db command state info
106-
event_scheduler localhost NULL Connect Waiting for next activation NULL
120+
event_scheduler localhost NULL Daemon Waiting for next activation NULL
107121
set global event_scheduler= 2;
108122
select * from events_smode_test order by ev_name, a;
109123
ev_name a
@@ -121,28 +135,30 @@ drop event ee_16407_3;
121135
drop event ee_16407_4;
122136
"And now one last test regarding sql_mode and call of SP from an event"
123137
delete from events_smode_test;
138+
set sql_mode='ansi';
139+
select get_lock('ee_16407_5', 60);
140+
get_lock('ee_16407_5', 60)
141+
1
142+
set global event_scheduler= 1;
124143
set sql_mode='traditional';
125144
create procedure ee_16407_5_pendant() begin insert into events_test.events_smode_test values('ee_16407_5','2001-02-29'); end|
126145
create procedure ee_16407_6_pendant() begin insert into events_test.events_smode_test values('ee_16407_6','2004-02-29'); end|
127146
create event ee_16407_5 on schedule every 60 second do
128147
begin
129148
select get_lock('ee_16407_5', 60) /*ee_16407_5*/;
149+
select release_lock('ee_16407_5');
130150
call events_test.ee_16407_5_pendant();
131151
end|
132152
create event ee_16407_6 on schedule every 60 second do
133153
begin
134154
select get_lock('ee_16407_5', 60) /*ee_16407_6*/;
155+
select release_lock('ee_16407_5');
135156
call events_test.ee_16407_6_pendant();
136157
end|
137-
set sql_mode='ansi';
138-
select get_lock('ee_16407_5', 60);
139-
get_lock('ee_16407_5', 60)
140-
1
141-
set global event_scheduler= 1;
142158
"Should have 2 locked processes"
143159
select /*4*/ user, host, db, command, state, info from information_schema.processlist where info is null or info not like '%processlist%' order by info;
144160
user host db command state info
145-
event_scheduler localhost NULL Connect Waiting for next activation NULL
161+
event_scheduler localhost NULL Daemon Waiting for next activation NULL
146162
root localhost events_test Connect User lock select get_lock('ee_16407_5', 60) /*ee_16407_5*/
147163
root localhost events_test Connect User lock select get_lock('ee_16407_5', 60) /*ee_16407_6*/
148164
select release_lock('ee_16407_5');
@@ -151,7 +167,7 @@ release_lock('ee_16407_5')
151167
"Should have 0 processes locked"
152168
select /*5*/ user, host, db, command, state, info from information_schema.processlist where info is null or info not like '%processlist%' order by info;
153169
user host db command state info
154-
event_scheduler localhost NULL Connect Waiting for next activation NULL
170+
event_scheduler localhost NULL Daemon Waiting for next activation NULL
155171
select * from events_smode_test order by ev_name, a;
156172
ev_name a
157173
ee_16407_6 2004-02-29

mysql-test/r/events_logs_tests.result

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ SELECT user_host, argument FROM mysql.general_log WHERE argument LIKE '%alabala%
99
END|
1010
"Check General Query Log"
1111
SET GLOBAL event_scheduler=2;
12-
create event log_general on schedule every 1 minute do SELect 'alabala', sleep(3) from dual;
12+
create event log_general on schedule every 1 minute do SELect 'alabala', sleep(1) from dual;
1313
TRUNCATE mysql.general_log;
1414
"1 row, the current statement!"
1515
call select_general_log();
@@ -19,7 +19,7 @@ SET GLOBAL event_scheduler=1;
1919
"Should see 3 rows - the 'SELect' is in the middle. The other two are selects from general_log"
2020
call select_general_log();
2121
user_host argument
22-
USER_HOST SELect 'alabala', sleep(3) from dual
22+
USER_HOST SELect 'alabala', sleep(1) from dual
2323
DROP PROCEDURE select_general_log;
2424
DROP EVENT log_general;
2525
SET GLOBAL event_scheduler=2;
@@ -49,13 +49,13 @@ USER_HOST SLEEPVAL events_test SELECT SLEEP(2)
4949
SET SESSION long_query_time=300;
5050
"Make it quite long"
5151
TRUNCATE mysql.slow_log;
52-
SET SESSION long_query_time=1;
5352
CREATE TABLE slow_event_test (slo_val tinyint, val tinyint);
5453
"This won't go to the slow log"
55-
CREATE EVENT long_event ON SCHEDULE EVERY 1 MINUTE DO INSERT INTO slow_event_test SELECT @@long_query_time, SLEEP(3);
5654
SELECT * FROM slow_event_test;
5755
slo_val val
56+
SET SESSION long_query_time=1;
5857
SET GLOBAL event_scheduler=1;
58+
CREATE EVENT long_event ON SCHEDULE EVERY 1 MINUTE DO INSERT INTO slow_event_test SELECT @@long_query_time, SLEEP(1.5);
5959
"Sleep some more time than the actual event run will take"
6060
SHOW VARIABLES LIKE 'event_scheduler';
6161
Variable_name Value
@@ -64,7 +64,7 @@ event_scheduler 1
6464
SELECT * FROM slow_event_test;
6565
slo_val val
6666
4 0
67-
"Check slow log. Should not see anything because 3 is under the threshold of 4 for GLOBAL, though over SESSION which is 2"
67+
"Check slow log. Should not see anything because 1.5 is under the threshold of 300 for GLOBAL, though over SESSION which is 2"
6868
SELECT user_host, query_time, db, sql_text FROM mysql.slow_log;
6969
user_host query_time db sql_text
7070
"This should go to the slow log"

mysql-test/r/events_scheduling.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ DROP EVENT start_n_end;
3939
DROP EVENT only_one_time;
4040
ERROR HY000: Unknown event 'only_one_time'
4141
"Should be preserved"
42-
SELECT EVENT_NAME, STATUS FROM INFORMATION_SCHEMA.EVENTS;
42+
SELECT EVENT_NAME, STATUS FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_NAME;
4343
EVENT_NAME STATUS
4444
E19170 ENABLED
4545
two_time DISABLED

mysql-test/t/events.test

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ CREATE EVENT e_x2 ON SCHEDULE EVERY 1 SECOND DO DROP TABLE x_table;
1818
connection default;
1919
SHOW DATABASES LIKE 'db_x';
2020
SET GLOBAL event_scheduler=1;
21-
--sleep 1.5
21+
--sleep 0.8
2222
SHOW DATABASES LIKE 'db_x';
2323
SHOW TABLES FROM db_x;
2424
SET GLOBAL event_scheduler=2;
@@ -83,7 +83,6 @@ DROP EVENT event_starts_test;
8383
#
8484
create table test_nested(a int);
8585
create event e_43 on schedule every 1 second do set @a = 5;
86-
set global event_scheduler = 1;
8786
--error 1562
8887
alter event e_43 do alter event e_43 do set @a = 4;
8988
delimiter |;
@@ -94,15 +93,15 @@ begin
9493
end|
9594
delimiter ;|
9695
set global event_scheduler = 1;
97-
--sleep 1
96+
--sleep 3
9897
select db, name, body, status, interval_field, interval_value from mysql.event;
9998
drop event e_43;
10099
drop table test_nested;
101100

102101
--echo "Let's check whether we can use non-qualified names"
103102
create table non_qualif(a int);
104103
create event non_qualif_ev on schedule every 10 minute do insert into non_qualif values (800219);
105-
--sleep 1
104+
--sleep 0.5
106105
select * from non_qualif;
107106
drop event non_qualif_ev;
108107
drop table non_qualif;
@@ -165,6 +164,10 @@ show create event root22;
165164
--error ER_NOT_SUPPORTED_YET
166165
SHOW EVENTS;
167166
drop event root22;
167+
--error ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG
168+
create event root23 on schedule every -100 year do select 1;
169+
--error ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG
170+
create event root23 on schedule every 222222222222222222222 year do select 1;
168171
drop event root6;
169172
drop event root7;
170173
drop event root8;
@@ -294,7 +297,7 @@ select get_lock("test_lock2", 20);
294297
--echo "Create an event which tries to acquire a mutex. The event locks on the mutex"
295298
create event закачка on schedule every 10 hour do select get_lock("test_lock2", 20);
296299
--echo "Let some time pass to the event starts"
297-
--sleep 1
300+
--sleep 0.5
298301
--echo "Should have only 2 processes: the scheduler and the locked event"
299302
select /*2*/ user, host, db, command, state, info from information_schema.processlist where info is null or info not like '%processlist%' order by info;--echo "Release the mutex, the event worker should finish."
300303
--echo "Release the mutex, the event worker should finish."
@@ -312,10 +315,11 @@ drop event закачка;
312315
set global event_scheduler=1;
313316
select get_lock("test_lock2_1", 20);
314317
create event закачка21 on schedule every 10 hour do select get_lock("test_lock2_1", 20);
315-
--sleep 1
318+
--sleep 0.5
316319
--echo "Should have only 3 processes: the scheduler, our conn and the locked event"
317320
select /*3*/ user, host, db, command, state, info from information_schema.processlist where info is null or info not like '%processlist%' order by info;
318321
set global event_scheduler=2;
322+
--sleep 0.3
319323
--echo "Should have only our process now:"
320324
select /*4*/ user, host, db, command, state, info from information_schema.processlist where info is null or info not like '%processlist%' order by info;
321325
drop event закачка21;

0 commit comments

Comments
 (0)