Error
Error Code: 1588

MariaDB Error 1588: Event execution time in past

📦 MariaDB
📋

Description

MariaDB Error 1588 occurs when you attempt to create or modify a scheduled event with an execution time that is already in the past. Due to the `ON COMPLETION NOT PRESERVE` setting, MariaDB immediately drops the event upon creation because its designated execution window has already closed.
💬

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

3 known causes
⚠️
Incorrect Event Schedule
The `STARTS` or `AT` clause in the `CREATE EVENT` statement specified a timestamp that has already passed relative to the server's current time.
⚠️
Time Zone Discrepancy
The time zone of the client or application creating the event differs from the MariaDB server's time zone, causing the event time to be interpreted as being in the past.
⚠️
Delayed Command Processing
The command to create the event was issued, but due to network latency or server load, it was processed after the specified `STARTS` or `AT` time had already elapsed.
🛠️

Solutions

4 solutions available

1. Schedule Event for the Future easy

Adjust the event's scheduled time to be in the future.

1
When creating or altering an event, ensure the `AT` clause specifies a time that is in the future relative to the current server time.
CREATE EVENT my_event ON SCHEDULE AT '2023-10-27 10:00:00'
DO
  -- your event logic here
2
Alternatively, if you are using a recurring schedule (`EVERY`), ensure that the initial `AT` time is also in the future.
CREATE EVENT my_recurring_event ON SCHEDULE EVERY 1 DAY STARTS '2023-10-27 10:00:00'
DO
  -- your event logic here

2. Use `INTERVAL` for Relative Scheduling easy

Schedule events based on a relative time interval from creation.

1
Instead of specifying an absolute date and time, use the `INTERVAL` keyword to schedule the event relative to its creation time. This is particularly useful for events that should run shortly after being defined.
CREATE EVENT my_relative_event ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 5 MINUTE
DO
  -- your event logic here
2
For recurring events, you can also use `INTERVAL` to define the start time.
CREATE EVENT my_recurring_relative_event ON SCHEDULE EVERY 1 HOUR STARTS CURRENT_TIMESTAMP + INTERVAL 1 HOUR
DO
  -- your event logic here

3. Modify `ON COMPLETION` Behavior (with Caution) medium

Change the `ON COMPLETION` clause to `PRESERVE` if the event should persist after its scheduled time.

1
If the event is intended to run only once and you want it to remain in the event scheduler's list even after its execution time has passed (e.g., for auditing or if you might re-enable it later), change `ON COMPLETION NOT PRESERVE` to `ON COMPLETION PRESERVE`.
CREATE EVENT my_event_to_preserve ON SCHEDULE AT '2023-10-27 10:00:00' ON COMPLETION PRESERVE
DO
  -- your event logic here
2
Alternatively, if the event is already created and you want to modify this setting, use `ALTER EVENT`.
ALTER EVENT my_event_to_preserve ON COMPLETION PRESERVE;
3
**Important Consideration:** Using `ON COMPLETION PRESERVE` for events that have already passed their execution time *without* rescheduling them will still result in the event being dropped immediately upon creation if its `AT` time is in the past. This solution is primarily for future-dated events that you want to keep in the scheduler's list after they have run.

4. Check and Adjust Server Time advanced

Verify that the MariaDB server's time is correctly synchronized.

1
Ensure that the system clock on your MariaDB server is accurate and synchronized with a reliable time source (e.g., NTP server). An incorrect system clock can lead to events being scheduled in the past unintentionally.
On Linux, use `timedatectl status` or `ntpq -p` to check NTP synchronization.
2
If the server time is incorrect, adjust it using `timedatectl set-time 'YYYY-MM-DD HH:MM:SS'` or by configuring NTP.
Example: `sudo timedatectl set-time '2023-10-27 10:30:00'`
3
After correcting the server time, you may need to drop and recreate any events that were affected by the time discrepancy.
🔗

Related Errors

5 related errors