Skip to content

Prevent multiple execution of aborted jobs #528

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
--------------------
Expand Down
8 changes: 8 additions & 0 deletions src/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading