From 073f25f673026792d2339261dfd74461d30f2904 Mon Sep 17 00:00:00 2001 From: Mitch Hagstrand Date: Thu, 17 Nov 2016 19:25:52 -0800 Subject: [PATCH] Fix bug where scheduler sleeps when processing a delayed queue The function handleDelayedItems() was overwriting the parameter $timestamp from the call nextDelayedTimestamp() with timestamp of the most delayed job. Therefor it would only process 1 seconds worth of items before sleeping. A slighty delayed queue could fall very far behind. --- lib/ResqueScheduler/Worker.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ResqueScheduler/Worker.php b/lib/ResqueScheduler/Worker.php index 73e0051..d0b4d30 100644 --- a/lib/ResqueScheduler/Worker.php +++ b/lib/ResqueScheduler/Worker.php @@ -55,9 +55,9 @@ public function work($interval = null) */ public function handleDelayedItems($timestamp = null) { - while (($timestamp = ResqueScheduler::nextDelayedTimestamp($timestamp)) !== false) { + while (($oldestJobTimestamp = ResqueScheduler::nextDelayedTimestamp($timestamp)) !== false) { $this->updateProcLine('Processing Delayed Items'); - $this->enqueueDelayedItemsForTimestamp($timestamp); + $this->enqueueDelayedItemsForTimestamp($oldestJobTimestamp); } }