Skip to content

Commit 26fb7fe

Browse files
authored
Fix #528: Prevent multiple execution of aborted jobs
1 parent d6372d8 commit 26fb7fe

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Yii2 Queue Extension Change Log
55
-----------------------
66
- Enh #516: Ensure Redis driver messages are consumed at least once (soul11201)
77
- Bug #522: Fix SQS driver type error with custom value passed to `queue/listen` (flaviovs)
8-
8+
- Bug #528: Prevent multiple execution of aborted jobs (luke-)
99

1010
2.3.7 April 29, 2024
1111
--------------------

src/Queue.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,14 @@ public function getWorkerPid()
225225
protected function handleMessage($id, $message, $ttr, $attempt)
226226
{
227227
list($job, $error) = $this->unserializeMessage($message);
228+
229+
// Handle aborted jobs without throwing an error.
230+
if ($attempt > 1 &&
231+
(($job instanceof RetryableJobInterface && !$job->canRetry($attempt - 1, $error))
232+
|| (!($job instanceof RetryableJobInterface) && $attempt > $this->attempts))) {
233+
return true;
234+
}
235+
228236
$event = new ExecEvent([
229237
'id' => $id,
230238
'job' => $job,

0 commit comments

Comments
 (0)