-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
Reopening: Queue priorities & block_for shouldn't be used together #51612
Comments
Does the same apply when using Horizon, since the sleep property is going to be at the supervisor level? |
@MohammadStemless Horizon is not used. The problem is in a stock Laravel from the repo and reproducible without supervisor. What do you mean by sleep property? If you talk about # config/queue.php:71
'block_for' => 1, // Default is null
1 second lag per job per queue.
No lag. |
“shouldn’t be used together” doesn’t sound right at all. It’s completely fine to use block_for and dequeue from multiple queues. Closing this since it's not a bug. |
@themsaid i'm not sure is my explanation and original author's is not enough, but please let me try explain the issue again. In your own video how In the case:
Expected result:100 jobs completed in 1 sec. Since there are jobs in the queue and worker can find jobs in Redis, Actual result100 jobs completed in 500 secs. When it does not happenIf a single queue is used there is no such problem and WorkaroundWhat original author says, and what we had to do as well is resetting |
We have dropped "block_for" setting from the project when ended up with 500.000 jobs in several queues. It does not work as it should. And I see a bizzare practice closing unresolved issues by Laravel team. |
+1 |
Laravel Version
All versions since 5.6 up to 9.19 and 11.9 at the moment
PHP Version
8.x
Queue driver
Redis
Description
This is a reopening of long standing issue. Original issue: #30728 was closed due to lack of confirmation if the issue exists in currently supported versions. I've tested actual ones, and the issue is still there up to the current 11.9.x.
For the convenience, copying essential parts of the original issue below:
If you use block_for and also utilize queue priorities, the worker will block on each queue sequentially. This could result in much longer queue processing times.
Steps To Reproduce
For example, suppose you set block_for=5 and spawn a worker like this:
The worker will block on the high queue for 5 seconds, then the medium queue, then the low queue, and finally the default queue. This means that it could take up to 15 seconds before a job in the default queue is picked up, even if it is the only job in any of the queues.
More seriously, if you set block_for=0 the worker will indefinitely block on the high queue, and the other queues will never be reached.
Solution:
I'm not sure if this is a bug, but I initially assumed that the worker would block on all the queues set for the worker and immediately pick up a new job in any of them.
Perhaps all that's needed is an addition to the documentation recommending that the block_for setting only be used when workers listen to a single queue...
The text was updated successfully, but these errors were encountered: