diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bdf0fc75..541d80ee0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ Yii2 Queue Extension Change Log ----------------------- - Enh #516: Ensure Redis driver messages are consumed at least once (soul11201) - Bug #522: Fix SQS driver type error with custom value passed to `queue/listen` (flaviovs) - +- Bug #528: Prevent multiple execution of aborted jobs (luke-) 2.3.7 April 29, 2024 -------------------- diff --git a/src/Queue.php b/src/Queue.php index 8182460e2..122bdb313 100644 --- a/src/Queue.php +++ b/src/Queue.php @@ -225,6 +225,14 @@ public function getWorkerPid() protected function handleMessage($id, $message, $ttr, $attempt) { list($job, $error) = $this->unserializeMessage($message); + + // Handle aborted jobs without throwing an error. + if ($attempt > 1 && + (($job instanceof RetryableJobInterface && !$job->canRetry($attempt - 1, $error)) + || (!($job instanceof RetryableJobInterface) && $attempt > $this->attempts))) { + return true; + } + $event = new ExecEvent([ 'id' => $id, 'job' => $job,