-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[5.3] Check attempts before firing queue job. #15319
Conversation
…oo many times. Resolves an issue with the `--timeout` feature where jobs the repeatedly timed out would never be marked as `failed`, as the worker process would be killed before it could reach the failing logic. To maintain compatibility there are now two checks against the number of attempts a job has had, one before working the job and one in the case of an job raising an exception. see laravel#15317 for more details.
@@ -251,6 +254,29 @@ protected function handleJobException($connectionName, $job, WorkerOptions $opti | |||
} | |||
|
|||
/** | |||
* Mark the given job as failed if it has exceeded the maximum allowed attempts. This will likely be because |
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.
Please add the rest of the description two lines down. :)
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.
Like this?
/**
* Mark the given job as failed if it has exceeded the maximum allowed attempts.
*
*
* This will likely be because the job previously exceeded a timeout.
*
* @param string $connectionName
* @param \Illuminate\Contracts\Queue\Job $job
* @param int $maxTries
* @return void
*/
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.
Nearly. I really meant two newline characters. :)
Just one star inbetween please.
Thanks for the PR. :) |
Pushed up your suggested style fixes GC. Let me know on any further |
@@ -89,10 +90,14 @@ public function test_job_is_not_released_if_it_has_exceeded_max_attempts() | |||
{ | |||
$e = new RuntimeException; | |||
|
|||
$job = new WorkerFakeJob(function () use ($e) { | |||
$job = new WorkerFakeJob(function ($job) use ($e) { | |||
|
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.
please remove this extra line
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.
fixed in 54d2c6b
I've also noticed the above issue @landish reported, you cannot just run This could be resolved by changing the conditional on from
to
Basically, I'm going to PR this fix. Also @maxbrokman nice work on this PR. Hope all is well. |
Looks like a bug. The default was meant to be unlimited retrys. |
I have the same problem as @landish says about the "markJobAsFailedIfAlreadyExceedsMaxAttempts" exception. |
Hi ! My case it is , I think, subtly different. I recently moved from 5.2 to 5.3 and my scheduled commands including these lines
are causing hundred of MySQL never dying processes (quite long Sleep status and mounting up). I've searched a lot and the closest issue is this one, but it does not look to be exact the same as, among others, I do not see any exceeded time exception in logs. |
Check jobs before working to see if they have already been received too many times.
Resolves an issue with the
--timeout
feature where jobs the repeatedly timed out would never be marked asfailed
, as the worker process would be killed beforeit could reach the failing logic.
To maintain compatibility there are now two checks against the number of attempts a job has had, one before working the job and one in the case of an job raising an exception.
see #15317 for more details.