Skip to content

Commit

Permalink
MDL-81689 tests: Check task DB record for nextruntime
Browse files Browse the repository at this point in the history
  • Loading branch information
jojoob authored and mickhawkins committed Jul 18, 2024
1 parent 615b78a commit 0d50449
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/classes/task/manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -807,8 +807,11 @@ function ($a, $b) use ($ordering) {

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]);
Expand Down

0 comments on commit 0d50449

Please sign in to comment.