Cron may double schedule jobs in edge case #10279
Labels
bug report
Issue: Clear Description
Gate 2 Passed. Manual verification of the issue description passed
Issue: Format is valid
Gate 1 Passed. Automatic verification of issue format passed
Uh oh!
There was an error while loading. Please reload this page.
Preconditions
Magento 2.1.3 (but I can see problem code has not changed in develop branch)
Steps to reproduce
These are a fairly artificial set of steps to reproduce the issue consistently, but the same situation can happen "in the wild" if the timings line up just right:
Expected result
When scheduler runs in step 3 above, it schedules a job for the next time increment beyond the cron run that is currently still in process.
Actual result
Instead, scheduler creates a pending job at the exact same time as the cron job that is in progress. Example result in the

cron_schedule
table:Root cause analysis
The problem is that when
ProcessCronQueueObserver::_generate()
assembles the array of existing cron schedules that later will be skipped insaveSchedule()
, it includes jobs only inpending
status, notrunning
status. At a minimum it should includerunning
jobs as well, and I would probably argue it shouldn't pay attention to the status of the job at all: if a record for the job exists incron_schedule
for the given time, regardless of status, it shouldn't ever be rescheduled for the same time.The text was updated successfully, but these errors were encountered: