diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bdf0fc75..5e4b7b901 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 2.3.7 April 29, 2024 -------------------- diff --git a/src/Queue.php b/src/Queue.php index 8182460e2..9a3376e4f 100644 --- a/src/Queue.php +++ b/src/Queue.php @@ -225,6 +225,16 @@ public function getWorkerPid() protected function handleMessage($id, $message, $ttr, $attempt) { list($job, $error) = $this->unserializeMessage($message); + + // Handle aborted jobs without thrown error + if ($attempt > 1) { + if ($job instanceof RetryableJobInterface && !$job->canRetry($attempt - 1, $error)) { + return true; + } elseif (!($job instanceof RetryableJobInterface) && $attempt > $this->attempts) { + return true; + } + } + $event = new ExecEvent([ 'id' => $id, 'job' => $job,