简体   繁体   中英

MySQL Scheduled Event Not Firing

I have so far been unsuccessful in getting any Scheduled Events to fire.

  • MySQL 5.7.14
  • Global variable event_scheduler is ON
  • Processlist shows event_scheduler with a status of "Waiting on empty queue"
  • This is a Master Server with server_id=2 and is replicated to Slaves.

The following query is used to create a scheduled event to clear out the sessions table (this is verbatim). The query itself works.

CREATE EVENT cleanup_session_data
ON SCHEDULE EVERY 1 DAY
ON COMPLETION PRESERVE
DISABLE ON SLAVE
DO
DELETE FROM session_data WHERE created_at < DATE_SUB(NOW(), INTERVAL 1 DAY);

However the Scheduled event simply does not fire.

Turns out the answer was to remove the

DISABLE ON SLAVE

Either it is my own misunderstanding or this does not work as expected. By not including the the EVENT status is "ENABLED" whereas with it included it is "SLAVESIDE_DISABLED"

The EVENTS now fire as expected. They are also not replicated to the SLAVE.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM