MDL-67596 cron: Allow runners to ramp up instantly

This commit is contained in:
Brendan Heywood 2020-01-01 21:26:29 +11:00
parent c55402486b
commit 286cc88c8c

View File

@ -96,7 +96,10 @@ function cron_run_scheduled_tasks(int $timenow) {
$scheduledlock = null;
for ($run = 0; $run < $maxruns; $run++) {
if ($scheduledlock = $cronlockfactory->get_lock("scheduled_task_runner_{$run}", 1)) {
// If we can't get a lock instantly it means runner N is already running
// so fail as fast as possible and try N+1 so we don't limit the speed at
// which we bring new runners into the pool.
if ($scheduledlock = $cronlockfactory->get_lock("scheduled_task_runner_{$run}", 0)) {
break;
}
}
@ -140,7 +143,10 @@ function cron_run_adhoc_tasks(int $timenow, $keepalive = 0, $checklimits = true)
if ($checklimits) {
$adhoclock = null;
for ($run = 0; $run < $maxruns; $run++) {
if ($adhoclock = $cronlockfactory->get_lock("adhoc_task_runner_{$run}", 1)) {
// If we can't get a lock instantly it means runner N is already running
// so fail as fast as possible and try N+1 so we don't limit the speed at
// which we bring new runners into the pool.
if ($adhoclock = $cronlockfactory->get_lock("adhoc_task_runner_{$run}", 0)) {
break;
}
}