-
Bug
-
Resolution: Duplicate
-
Minor
-
None
-
4.1 regressions
-
None
Under specific circumstances and due to the caching of queued tasks ($miniqueue) in the task managers get_next_adhoc_task() function a task that was marked as failed is getting re-executed right after, ignoring the new nextruntime/faildelay.
For the bug to get triggered it is required that the number of "unique tasks" (tasks from different classes) do not change between subsequent calls of manager::get_next_adhoc_task():
$uniquetasksinqueue = array_map(
|
['\core\task\manager', 'adhoc_task_from_record'], |
$DB->get_records_sql(
|
'SELECT classname FROM {task_adhoc} WHERE nextruntime < :timestart GROUP BY classname', |
['timestart' => $timestart] |
)
|
); if (!isset(self::$numtasks) || self::$numtasks !== count($uniquetasksinqueue)) { |
self::$numtasks = count($uniquetasksinqueue);
|
self::$miniqueue = [];
|
}
|
The occurrence of the bug can be seen in the task log showing multiple entries for the same task id with a started timestamp just a few seconds apart. I also verified the bug by reviewing the code and inserting a debug output into the foreach loop of the get_next_adhoc_task() function:
if ($record->nextruntime >= $timestart) { |
mtrace("Running a task with its nextruntime ($record->nextruntime) in the future (now: $timestart). Oups!"); |
}
|
This bug was introduced with MDL-67648 and is still present on the master branch.
- duplicates
-
MDL-81689 Failing adhoc tasks sometimes run twice ignoring nextruntime/faildelay
- Closed