-
-
Notifications
You must be signed in to change notification settings - Fork 292
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
base: master
Are you sure you want to change the base?
Changes from 3 commits
95c21de
83fac4c
2c5d0ff
18e342f
14bfe70
1cbc278
99d9f89
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -225,6 +225,17 @@ 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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that all this can be combined into one condition There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @s1lver Shall I summarize that? I'd be happy to. I personally prefer the breakdown for quick readability. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about this solution? Will return true if any of the conditions evaluate to true return
($job instanceof RetryableJobInterface && !$job->canRetry($attempt - 1, $error))
|| (!($job instanceof RetryableJobInterface) && $attempt > $this->attempts) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
if ($job instanceof RetryableJobInterface && !$job->canRetry($attempt - 1, $error)) { | ||
return true; | ||
} else { | ||
// Non RetryableJobs can have a maximum of one attempt | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This assumption is incorrect. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rob006 Thanks for pointing that out. I've adjusted the condition. |
||
return true; | ||
} | ||
} | ||
|
||
$event = new ExecEvent([ | ||
'id' => $id, | ||
'job' => $job, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.