From dbf19da9ca9830fa79fffd4dcb2331a6c5c3e318 Mon Sep 17 00:00:00 2001 From: Paras Malhotra Date: Sat, 3 Oct 2020 18:36:19 +0530 Subject: [PATCH 1/2] [8.x] Fix queue clearing when blocking --- src/Illuminate/Queue/LuaScripts.php | 3 ++- src/Illuminate/Queue/RedisQueue.php | 3 ++- tests/Queue/RedisQueueIntegrationTest.php | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Queue/LuaScripts.php b/src/Illuminate/Queue/LuaScripts.php index c592ae3dbd75..45d31075fdef 100644 --- a/src/Illuminate/Queue/LuaScripts.php +++ b/src/Illuminate/Queue/LuaScripts.php @@ -133,6 +133,7 @@ public static function migrateExpiredJobs() * KEYS[1] - The name of the primary queue * KEYS[2] - The name of the "delayed" queue * KEYS[3] - The name of the "reserved" queue + * KEYS[4] - The name of the "notify" queue * * @return string */ @@ -140,7 +141,7 @@ public static function clear() { return <<<'LUA' local size = redis.call('llen', KEYS[1]) + redis.call('zcard', KEYS[2]) + redis.call('zcard', KEYS[3]) -redis.call('del', KEYS[1], KEYS[2], KEYS[3]) +redis.call('del', KEYS[1], KEYS[2], KEYS[3], KEYS[4]) return size LUA; } diff --git a/src/Illuminate/Queue/RedisQueue.php b/src/Illuminate/Queue/RedisQueue.php index 56bfbd5e46b9..9fdeb4d51795 100644 --- a/src/Illuminate/Queue/RedisQueue.php +++ b/src/Illuminate/Queue/RedisQueue.php @@ -298,7 +298,8 @@ public function clear($queue) $queue = $this->getQueue($queue); return $this->getConnection()->eval( - LuaScripts::clear(), 3, $queue, $queue.':delayed', $queue.':reserved' + LuaScripts::clear(), 4, $queue, $queue.':delayed', + $queue.':reserved', $queue.':notify' ); } diff --git a/tests/Queue/RedisQueueIntegrationTest.php b/tests/Queue/RedisQueueIntegrationTest.php index 3381e03fee4d..0380988bd4e1 100644 --- a/tests/Queue/RedisQueueIntegrationTest.php +++ b/tests/Queue/RedisQueueIntegrationTest.php @@ -431,6 +431,7 @@ public function testClear($driver) $this->assertEquals(2, $this->queue->clear(null)); $this->assertEquals(0, $this->queue->size()); + $this->assertEquals(0, $this->redis[$driver]->connection()->llen('queues:default:notify')); } /** From 87ff574bdbde2eed7734e05379a288433d6734f7 Mon Sep 17 00:00:00 2001 From: Paras Malhotra Date: Sat, 3 Oct 2020 18:43:16 +0530 Subject: [PATCH 2/2] fix styleci --- src/Illuminate/Queue/RedisQueue.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Queue/RedisQueue.php b/src/Illuminate/Queue/RedisQueue.php index 9fdeb4d51795..19fc07589497 100644 --- a/src/Illuminate/Queue/RedisQueue.php +++ b/src/Illuminate/Queue/RedisQueue.php @@ -298,7 +298,7 @@ public function clear($queue) $queue = $this->getQueue($queue); return $this->getConnection()->eval( - LuaScripts::clear(), 4, $queue, $queue.':delayed', + LuaScripts::clear(), 4, $queue, $queue.':delayed', $queue.':reserved', $queue.':notify' ); }