Skip to content

Commit 060e421

Browse files
netpoktaylorotwell
authored andcommitted
Make job fail only if it not failed already (#20654)
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.
1 parent 77703e4 commit 060e421

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Illuminate/Queue/Worker.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,11 @@ protected function handleJobException($connectionName, $job, WorkerOptions $opti
343343
// First, we will go ahead and mark the job as failed if it will exceed the maximum
344344
// attempts it is allowed to run the next time we process it. If so we will just
345345
// go ahead and mark it as failed now so we do not have to release this again.
346-
$this->markJobAsFailedIfWillExceedMaxAttempts(
347-
$connectionName, $job, (int) $options->maxTries, $e
348-
);
346+
if (! $job->hasFailed()) {
347+
$this->markJobAsFailedIfWillExceedMaxAttempts(
348+
$connectionName, $job, (int) $options->maxTries, $e
349+
);
350+
}
349351

350352
$this->raiseExceptionOccurredJobEvent(
351353
$connectionName, $job, $e

0 commit comments

Comments
 (0)