mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-68768 tool_tasks: Check for failing adhoc tasks
This commit is contained in:
parent
c307f3b138
commit
71f180447a
@ -79,6 +79,19 @@ class maxfaildelay extends check {
|
||||
}
|
||||
}
|
||||
|
||||
$tasks = \core\task\manager::get_failed_adhoc_tasks();
|
||||
foreach ($tasks as $task) {
|
||||
$faildelay = $task->get_fail_delay();
|
||||
if ($faildelay > $maxdelay) {
|
||||
$maxdelay = $faildelay;
|
||||
}
|
||||
if ($faildelay > 0) {
|
||||
$failures++;
|
||||
$details .= get_string('faildelay', 'tool_task') . ': ' . format_time($faildelay);
|
||||
$details .= ' - ' .get_class($task) . " ID = " . $task->get_id() ."<br>";
|
||||
}
|
||||
}
|
||||
|
||||
if ($failures > 0) {
|
||||
// Intermittent failures are not yet a warning.
|
||||
$status = result::INFO;
|
||||
|
@ -511,6 +511,27 @@ class manager {
|
||||
return $tasks;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will return a list of all adhoc tasks that have a faildelay
|
||||
*
|
||||
* @param int $delay filter how long the task has been delayed
|
||||
* @return \core\task\adhoc_task[]
|
||||
*/
|
||||
public static function get_failed_adhoc_tasks(int $delay = 0): array {
|
||||
global $DB;
|
||||
|
||||
$tasks = [];
|
||||
$records = $DB->get_records_sql('SELECT * from {task_adhoc} WHERE faildelay > ?', [$delay]);
|
||||
|
||||
foreach ($records as $record) {
|
||||
$task = self::adhoc_task_from_record($record);
|
||||
if ($task) {
|
||||
$tasks[] = $task;
|
||||
}
|
||||
}
|
||||
return $tasks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure quality of service for the ad hoc task queue.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user