MDL-81689 tests: Check task DB record for nextruntime

This commit is contained in:
Johannes Burk
2024-07-26 10:30:40 +02:00
parent ae65a413a0
commit 3ba36a9082
+5 -2
View File
@@ -807,8 +807,11 @@ class manager {
if ($lock = $cronlockfactory->get_lock('adhoc_' . $record->id, 0)) {
// Safety check, see if the task has been already processed by another cron run.
$record = $DB->get_record('task_adhoc', array('id' => $record->id));
// Safety check, see if the task has already been processed by another cron run (or attempted and failed).
// If another cron run attempted to process the task and failed, nextruntime will be in the future.
$record = $DB->get_record_select('task_adhoc',
"id = :id AND nextruntime < :timestart",
['id' => $record->id, 'timestart' => $timestart]);
if (!$record) {
$lock->release();
unset(self::$miniqueue[$taskid]);