Error
Error Code: 1543

MariaDB Error 1543: Event End Time Before Start

📦 MariaDB
📋

Description

This error occurs when attempting to create or modify a scheduled event in MariaDB where the specified 'ENDS' timestamp is chronologically earlier than the 'STARTS' timestamp. It also triggers if the 'ENDS' value is in an invalid date/time format. This prevents the event from being successfully defined, as an event cannot logically conclude before it has begun.
💬

Error Message

ENDS is either invalid or before STARTS
🔍

Known Causes

3 known causes
⚠️
Incorrect Event Time Order
The 'ENDS' timestamp for the scheduled event is specified with a date and/or time that occurs chronologically before the 'STARTS' timestamp.
⚠️
Invalid ENDS Format
The value provided for the 'ENDS' timestamp does not conform to MariaDB's expected datetime format, making it unparseable.
⚠️
Time Zone Discrepancies
Differences in time zone settings between the server, session, or application can lead to an apparent end time before start time.
🛠️

Solutions

3 solutions available

1. Correct Event Schedule Time Values easy

Adjust the `STARTS` and `ENDS` datetime values to ensure `ENDS` is after `STARTS`.

1
Identify the `CREATE EVENT` or `ALTER EVENT` statement that is causing the error. Look for the `STARTS` and `ENDS` clauses.
SELECT * FROM information_schema.events WHERE event_name = 'your_event_name';
2
Modify the `STARTS` and `ENDS` datetime values. The `ENDS` datetime must be chronologically after the `STARTS` datetime. Ensure correct 'YYYY-MM-DD HH:MM:SS' format.
ALTER EVENT your_event_name ON SCHEDULE EVERY 1 DAY STARTS '2023-10-27 08:00:00' ENDS '2023-10-27 10:00:00';
3
If the event is meant to be recurring, ensure the `ENDS` time is not before the *next* occurrence of the `STARTS` time if the event has already run past its intended end date. For a one-off event, ensure `ENDS` is after `STARTS` on the same day or a future day.
ALTER EVENT your_event_name ON SCHEDULE AT '2023-10-27 08:00:00' ENDS '2023-10-28 08:00:00';

2. Remove or Reset Event Scheduler easy

Temporarily disable the event scheduler or remove the problematic event.

1
Check the current status of the event scheduler.
SHOW VARIABLES LIKE 'event_scheduler';
2
If the scheduler is ON and you need to quickly resolve the issue without fixing the event, you can turn it OFF. This will stop all scheduled events from running.
SET GLOBAL event_scheduler = OFF;
3
Alternatively, you can drop the specific event causing the error.
DROP EVENT IF EXISTS your_event_name;
4
After resolving the event schedule or dropping the event, you can re-enable the scheduler if needed.
SET GLOBAL event_scheduler = ON;

3. Verify Event Execution Context and Time Zones medium

Ensure the server's time zone and the event's intended time zone are consistent.

1
Check the MariaDB server's time zone setting.
SELECT @@global.time_zone, @@session.time_zone;
2
If the server's time zone is not set or is set to 'SYSTEM', verify the operating system's time zone. Inconsistent time zones between the OS and MariaDB can lead to misinterpretations of event start and end times.
# On Linux:
ls -l /etc/localtime
3
If the time zones are mismatched and causing the error, you can set the global time zone for MariaDB (requires SUPER privilege). For example, to set it to UTC:
SET GLOBAL time_zone = '+00:00';
4
When creating or altering events, explicitly specify the time zone if it differs from the server's default, or ensure your `STARTS` and `ENDS` times are relative to the server's current time zone.
ALTER EVENT your_event_name ON SCHEDULE EVERY 1 DAY STARTS '2023-10-27 08:00:00' ENDS '2023-10-27 10:00:00' AT TIME ZONE 'UTC';
🔗

Related Errors

5 related errors