mirror of
https://github.com/moodle/moodle.git
synced 2025-04-20 07:56:06 +02:00
Merge branch 'MDL-67486-swap-cron-lock' of https://github.com/brendanheywood/moodle
This commit is contained in:
commit
2bdad64e48
@ -566,9 +566,6 @@ class manager {
|
||||
$records = self::ensure_adhoc_task_qos($records);
|
||||
|
||||
$cronlockfactory = \core\lock\lock_config::get_lock_factory('cron');
|
||||
if (!$cronlock = $cronlockfactory->get_lock('core_cron', 10)) {
|
||||
throw new \moodle_exception('locktimeout');
|
||||
}
|
||||
|
||||
$skipclasses = array();
|
||||
|
||||
@ -608,6 +605,13 @@ class manager {
|
||||
}
|
||||
}
|
||||
|
||||
// The global cron lock is under the most contention so request it
|
||||
// as late as possible and release it as soon as possible.
|
||||
if (!$cronlock = $cronlockfactory->get_lock('core_cron', 10)) {
|
||||
$lock->release();
|
||||
throw new \moodle_exception('locktimeout');
|
||||
}
|
||||
|
||||
$task->set_lock($lock);
|
||||
if (!$task->is_blocking()) {
|
||||
$cronlock->release();
|
||||
@ -618,8 +622,6 @@ class manager {
|
||||
}
|
||||
}
|
||||
|
||||
// No tasks.
|
||||
$cronlock->release();
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -636,10 +638,6 @@ class manager {
|
||||
global $DB;
|
||||
$cronlockfactory = \core\lock\lock_config::get_lock_factory('cron');
|
||||
|
||||
if (!$cronlock = $cronlockfactory->get_lock('core_cron', 10)) {
|
||||
throw new \moodle_exception('locktimeout');
|
||||
}
|
||||
|
||||
$where = "(lastruntime IS NULL OR lastruntime < :timestart1)
|
||||
AND (nextruntime IS NULL OR nextruntime < :timestart2)
|
||||
AND disabled = 0
|
||||
@ -678,6 +676,13 @@ class manager {
|
||||
continue;
|
||||
}
|
||||
|
||||
// The global cron lock is under the most contention so request it
|
||||
// as late as possible and release it as soon as possible.
|
||||
if (!$cronlock = $cronlockfactory->get_lock('core_cron', 10)) {
|
||||
$lock->release();
|
||||
throw new \moodle_exception('locktimeout');
|
||||
}
|
||||
|
||||
if (!$task->is_blocking()) {
|
||||
$cronlock->release();
|
||||
} else {
|
||||
@ -687,8 +692,6 @@ class manager {
|
||||
}
|
||||
}
|
||||
|
||||
// No tasks.
|
||||
$cronlock->release();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user