Andrei Elkin <andrei.el...@mariadb.com> writes:

>> My question is if it is ok and by design that the event can continue running
>> after the scheduler is stopped and even after the event is dropped? That

> Should not be ok. The docs https://mariadb.com/kb/en/drop-event/
>
> are explicit
>
>  Description
>   This statement drops the event named event_name. The event immediately 
> ceases being active, and is deleted completely from the server.

Thanks for the link, Andrei!

Interesting, this doesn't seem to be how it works. This small test starts an
event that runs for 3 seconds, but drops the event after 1 second:

-----------------------------------------------------------------------
SET GLOBAL event_scheduler= OFF;
CREATE TABLE t1(a INT);
CREATE EVENT ev1 ON SCHEDULE EVERY 5 SECOND DO INSERT INTO t1 VALUES(SLEEP(3));
SET GLOBAL event_scheduler= ON;
--sleep 1
SHOW FULL PROCESSLIST;
SET GLOBAL event_scheduler= OFF;
DROP EVENT ev1;
SHOW FULL PROCESSLIST;
--sleep 1
SHOW FULL PROCESSLIST;
DROP TABLE t1;
-----------------------------------------------------------------------

The already-started instance of the event happily continues to run after
being dropped. I wonder if that's a bug, or if the documentation is wrong?
And if it is a bug, if there are any use-after-free or similar memory issues
with the event continuing to run after being dropped? Valgrind doesn't
complain...

-----------------------------------------------------------------------
SET GLOBAL event_scheduler= OFF;
CREATE TABLE t1(a INT);
CREATE EVENT ev1 ON SCHEDULE EVERY 5 SECOND DO INSERT INTO t1 VALUES(SLEEP(3));
Warnings:
Warning 1105    Event scheduler is switched off, use SET GLOBAL 
event_scheduler=ON to enable it.
SET GLOBAL event_scheduler= ON;
SHOW FULL PROCESSLIST;
Id      User    Host    db      Command Time    State   Info    Progress
4       root    localhost       test    Query   0       starting        SHOW 
FULL PROCESSLIST   0.000
5       event_scheduler localhost       NULL    Daemon  1       Waiting for 
next activation     NULL    0.000
6       root    localhost       test    Connect 1       User sleep      INSERT 
INTO t1 VALUES(SLEEP(3)) 0.000
SET GLOBAL event_scheduler= OFF;
DROP EVENT ev1;
SHOW FULL PROCESSLIST;
Id      User    Host    db      Command Time    State   Info    Progress
4       root    localhost       test    Query   0       starting        SHOW 
FULL PROCESSLIST   0.000
6       root    localhost       test    Connect 1       User sleep      INSERT 
INTO t1 VALUES(SLEEP(3)) 0.000
SHOW FULL PROCESSLIST;
Id      User    Host    db      Command Time    State   Info    Progress
4       root    localhost       test    Query   0       starting        SHOW 
FULL PROCESSLIST   0.000
6       root    localhost       test    Connect 2       User sleep      INSERT 
INTO t1 VALUES(SLEEP(3)) 0.000
DROP TABLE t1;
-----------------------------------------------------------------------

 - Kristian.
_______________________________________________
developers mailing list -- developers@lists.mariadb.org
To unsubscribe send an email to developers-le...@lists.mariadb.org

Reply via email to