You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And you'll see that the second worker picked up the same job around second 15 that the first worker was processing it.
If you remove the + $options->sleep from the Worker, then the first worker gets killed (correctly, IMO) at 10s and the second picks the job up 5s later when Amazon makes it visible again.
The docs clearly and correctly state that
The --timeout value should always be at least several seconds shorter than your retry_after configuration value. This will ensure that a worker processing a given job is always killed before the job is retried. If your --timeout option is longer than your retry_after configuration value, your jobs may be processed twice.
(Of course, SQS doesn't use retry_after, but rather the visibility timeout.)
In this case I followed the warning of the docs and made my timeout of 10s several seconds shorter than my retry_after (visibility) of 15s, yet still got bit by this. This isn't a theoretical problem, I actually had a few jobs processed twice due to this. It's not a catastrophic issue, but I do think fixing it could make Laravel even better.
At the very least, the docs should warn that the sleep value will be added to your timeout value and you should set your retry_after value several seconds longer than the sum of those two values.
The text was updated successfully, but these errors were encountered:
Description:
I think I've stumbled on to an issue where a queue can process the same job twice due to this line in the queue worker: https://github.com/laravel/framework/blob/5.4/src/Illuminate/Queue/Worker.php#L144.
Specifically, because the
+ $options->sleep
is added in there.Steps To Reproduce:
TestJob
with a$timeout
of 10s, wherehandle
is:TestJob
to the queue.--sleep=10
You'll see one worker chug through and end with:
And you'll see that the second worker picked up the same job around second 15 that the first worker was processing it.
If you remove the
+ $options->sleep
from the Worker, then the first worker gets killed (correctly, IMO) at 10s and the second picks the job up 5s later when Amazon makes it visible again.The docs clearly and correctly state that
(Of course, SQS doesn't use
retry_after
, but rather the visibility timeout.)In this case I followed the warning of the docs and made my timeout of
10s
several seconds shorter than myretry_after
(visibility) of15s
, yet still got bit by this. This isn't a theoretical problem, I actually had a few jobs processed twice due to this. It's not a catastrophic issue, but I do think fixing it could make Laravel even better.At the very least, the docs should warn that the
sleep
value will be added to yourtimeout
value and you should set yourretry_after
value several seconds longer than the sum of those two values.The text was updated successfully, but these errors were encountered: