Error
Error Code: 1589

MariaDB Error 1589: Past Event Time, Event Dropped

📦 MariaDB
📋

Description

This error indicates that a scheduled MariaDB event was defined with an execution time (`AT` clause) that is already in the past. Because the `ON COMPLETION NOT PRESERVE` option was either explicitly set or is the default, MariaDB immediately dropped the event without executing it. This prevents the event from running at all.
💬

Error Message

Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation.
🔍

Known Causes

4 known causes
⚠️
Event `AT` Time in Past
The `AT` timestamp specified in the `CREATE EVENT` or `ALTER EVENT` statement is a date and time that has already passed relative to the server's current time.
⚠️
`ON COMPLETION NOT PRESERVE` Set
The event was explicitly or implicitly configured with `ON COMPLETION NOT PRESERVE`, which tells MariaDB to drop the event immediately after its final execution or if its execution time is in the past.
⚠️
Time Zone Mismatch
A discrepancy between the client's local time zone (where the event statement was written) and the MariaDB server's configured time zone can cause the event's `AT` time to be interpreted as being in the past.
⚠️
Incorrect Server System Clock
The MariaDB server's underlying operating system clock might be set incorrectly or has drifted, causing it to perceive a valid future `AT` timestamp as being in the past.
🛠️

Solutions

3 solutions available

1. Correct Event Schedule to Future Time easy

Adjust the event's schedule to a future timestamp.

1
Identify the event that caused the error. You can usually find this in your application logs or by querying the `mysql.event` table if you have access.
SELECT * FROM mysql.event WHERE event_name = 'your_event_name';
-- Replace 'your_event_name' with the actual name of your event.
2
Determine the current time and identify a suitable future time for the event to execute. Ensure this time is after the event's creation time.
SELECT NOW();
3
Alter the event to set its `EXECUTE AT` or `STARTS` clause to the corrected future time. If you are using `INTERVAL` based scheduling, ensure the interval is valid from the current time.
ALTER EVENT your_event_name ON SCHEDULE AT 'YYYY-MM-DD HH:MM:SS';
-- Or for recurring events:
ALTER EVENT your_event_name ON SCHEDULE EVERY 1 DAY STARTS 'YYYY-MM-DD HH:MM:SS';
-- Replace 'your_event_name' and the timestamp with your specific details.
4
Verify the event's schedule has been updated correctly.
SHOW EVENTS LIKE 'your_event_name';

2. Modify Event to Preserve Completion Status easy

Change the event's `ON COMPLETION` clause to `PRESERVE`.

1
Identify the event that caused the error.
SELECT * FROM mysql.event WHERE event_name = 'your_event_name';
2
Alter the event to set `ON COMPLETION PRESERVE`. This will prevent the event from being dropped if its execution time is in the past, allowing it to be rescheduled.
ALTER EVENT your_event_name ON COMPLETION PRESERVE;
-- Replace 'your_event_name' with the actual name of your event.
3
After making this change, you will likely need to reschedule the event to a future time as described in 'Correct Event Schedule to Future Time' if you want it to run again.
ALTER EVENT your_event_name ON SCHEDULE AT 'YYYY-MM-DD HH:MM:SS';
4
Verify the event's `ON COMPLETION` clause and schedule.
SHOW EVENTS LIKE 'your_event_name';

3. Recreate Event with Corrected Schedule medium

Drop and recreate the event with a valid future schedule.

1
Back up the definition of the event you intend to recreate. This will help you rebuild it accurately.
SHOW CREATE EVENT your_event_name;
2
Drop the problematic event.
DROP EVENT your_event_name;
3
Recreate the event using the information from the `SHOW CREATE EVENT` command, ensuring the `EXECUTE AT` or `STARTS` clause is set to a valid future time. If you intended the event to be a one-time execution and it's in the past, set a future `EXECUTE AT` time. If it's a recurring event, ensure the `STARTS` time is in the future.
-- Example for a one-time event:
CREATE EVENT your_event_name
ON SCHEDULE AT 'YYYY-MM-DD HH:MM:SS'
DO
  -- your SQL statement(s) here;

-- Example for a recurring event:
CREATE EVENT your_event_name
ON SCHEDULE EVERY 1 DAY STARTS 'YYYY-MM-DD HH:MM:SS'
DO
  -- your SQL statement(s) here;
4
Verify the new event has been created with the correct schedule.
SHOW EVENTS LIKE 'your_event_name';
🔗

Related Errors

5 related errors