Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] Ensure ShouldBeUniqueUntilProcessing job lock is released once #35270

Merged
merged 2 commits into from Nov 18, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 6 additions & 12 deletions src/Illuminate/Queue/CallQueuedHandler.php
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -179,7 +172,7 @@ protected function ensureSuccessfulBatchJobIsRecorded($command)
*/
protected function ensureUniqueJobLockIsReleased($command)
{
if (! $command instanceof ShouldBeUnique || $this->uniqueLockReleased) {
if (! $command instanceof ShouldBeUnique) {
return;
}

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

$this->uniqueLockReleased = true;
}

/**
Expand Down Expand Up @@ -237,7 +228,10 @@ 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);

Expand Down