Skip to content

Commit

Permalink
Ensure unique job lock is released only once in lifecycle
Browse files Browse the repository at this point in the history
  • Loading branch information
paras-malhotra committed Nov 18, 2020
1 parent 72306be commit 2a6e9d3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/Illuminate/Queue/CallQueuedHandler.php
Expand Up @@ -29,6 +29,13 @@ class CallQueuedHandler
*/
protected $container;

/**
* Indicates if the unique job lock has been released.
*
* @var bool
*/
protected $uniqueLockReleased = false;

/**
* Create a new handler instance.
*
Expand Down Expand Up @@ -171,7 +178,7 @@ protected function ensureSuccessfulBatchJobIsRecorded($command)
*/
protected function ensureUniqueJobLockIsReleased($command)
{
if (! $command instanceof ShouldBeUnique) {
if (! ($command instanceof ShouldBeUnique) || $this->uniqueLockReleased) {
return;
}

Expand All @@ -186,6 +193,8 @@ protected function ensureUniqueJobLockIsReleased($command)
$cache->lock(
'laravel_unique_job:'.get_class($command).$uniqueId
)->forceRelease();

$this->uniqueLockReleased = true;
}

/**
Expand Down

0 comments on commit 2a6e9d3

Please sign in to comment.