From 91aeea4a126d38dd21a2fdde73dcc87c8e0bafaf Mon Sep 17 00:00:00 2001 From: Paras Malhotra Date: Wed, 18 Nov 2020 20:12:30 +0530 Subject: [PATCH 1/2] [8.x] Ensure unique lock is released once --- src/Illuminate/Queue/CallQueuedHandler.php | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/Illuminate/Queue/CallQueuedHandler.php b/src/Illuminate/Queue/CallQueuedHandler.php index cc3d8934ca4a..180a153c968d 100644 --- a/src/Illuminate/Queue/CallQueuedHandler.php +++ b/src/Illuminate/Queue/CallQueuedHandler.php @@ -30,13 +30,6 @@ class CallQueuedHandler */ protected $container; - /** - * Indicates if the unique job lock has been released. - * - * @var bool - */ - protected $uniqueLockReleased = false; - /** * Create a new handler instance. * @@ -73,7 +66,7 @@ public function call(Job $job, array $data) $this->dispatchThroughMiddleware($job, $command); - if (! $job->isReleased()) { + if (! $job->isReleased() && ! $command instanceof ShouldBeUniqueUntilProcessing) { $this->ensureUniqueJobLockIsReleased($command); } @@ -179,7 +172,7 @@ protected function ensureSuccessfulBatchJobIsRecorded($command) */ protected function ensureUniqueJobLockIsReleased($command) { - if (! $command instanceof ShouldBeUnique || $this->uniqueLockReleased) { + if (! $command instanceof ShouldBeUnique) { return; } @@ -194,8 +187,6 @@ protected function ensureUniqueJobLockIsReleased($command) $cache->lock( 'laravel_unique_job:'.get_class($command).$uniqueId )->forceRelease(); - - $this->uniqueLockReleased = true; } /** @@ -237,7 +228,9 @@ public function failed(array $data, $e, string $uuid) { $command = unserialize($data['command']); - $this->ensureUniqueJobLockIsReleased($command); + if (! $command instanceof ShouldBeUniqueUntilProcessing) { + $this->ensureUniqueJobLockIsReleased($command); + } $this->ensureFailedBatchJobIsRecorded($uuid, $command, $e); $this->ensureChainCatchCallbacksAreInvoked($uuid, $command, $e); From e87306bfa67575c7e0d81afac2d3ffd750d7fc28 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 18 Nov 2020 08:49:02 -0600 Subject: [PATCH 2/2] Update CallQueuedHandler.php --- src/Illuminate/Queue/CallQueuedHandler.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Illuminate/Queue/CallQueuedHandler.php b/src/Illuminate/Queue/CallQueuedHandler.php index 180a153c968d..adb7b19e11b9 100644 --- a/src/Illuminate/Queue/CallQueuedHandler.php +++ b/src/Illuminate/Queue/CallQueuedHandler.php @@ -231,6 +231,7 @@ public function failed(array $data, $e, string $uuid) if (! $command instanceof ShouldBeUniqueUntilProcessing) { $this->ensureUniqueJobLockIsReleased($command); } + $this->ensureFailedBatchJobIsRecorded($uuid, $command, $e); $this->ensureChainCatchCallbacksAreInvoked($uuid, $command, $e);