Skip to content

Commit

Permalink
Make job fail only if it not failed already
Browse files Browse the repository at this point in the history
This will prevent calling statsJob on an already failed and therefore deleted job, which would create another exception.

In case of beanstalk queue driver this will make queue worker to correctly report MaxAttemptsExceededException instead of Pheanstalk ServerException.
  • Loading branch information
netpok committed Aug 21, 2017
1 parent ef6177f commit 5a63b40
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Illuminate/Queue/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,11 @@ protected function handleJobException($connectionName, $job, WorkerOptions $opti
// First, we will go ahead and mark the job as failed if it will exceed the maximum
// attempts it is allowed to run the next time we process it. If so we will just
// go ahead and mark it as failed now so we do not have to release this again.
$this->markJobAsFailedIfWillExceedMaxAttempts(
$connectionName, $job, (int) $options->maxTries, $e
);
if (! $job->hasFailed()) {
$this->markJobAsFailedIfWillExceedMaxAttempts(
$connectionName, $job, (int) $options->maxTries, $e
);
}

$this->raiseExceptionOccurredJobEvent(
$connectionName, $job, $e
Expand Down

0 comments on commit 5a63b40

Please sign in to comment.