BUG: Recorder scheduler enqueueNextOccurrence does not check end_at < start_at for cloned rows #67
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Bug
When a recurring schedule completes,
enqueueNextOccurrenceclones the schedule forward by N days:Problem
There is no runtime-length cap. If someone creates a daily schedule with a 48-hour duration (start=Jan 1 00:00, end=Jan 2 00:00), the cloned row has the same duration each day. No problem there.
BUT: if the original schedule's
durationis negative (start > end — which can't happen due to theend_at > start_atCHECK constraint on the original insert), the cloned row would also be negative.More importantly: if a recurring schedule's window doesn't fit in the next day (e.g., start=23:00, duration=2h — should span midnight), the cloned timestamp
start_at + 1 dayis correct, butend_at + 1 daycorrectly extends past midnight. This is fine.Real bug: The cloned row is always
'pending'status regardless of whether it should already be running. If the scheduler was down for 24 hours, when it comes back it will create the next occurrence and skip the immediate window becausetick()only scansstart_at <= NOW() AND end_at > NOW. The cloned window could be fully in the past and would be ignored until the next restart.Impact
Location
services/mam-api/src/scheduler.js:118-128