-
Notifications
You must be signed in to change notification settings - Fork 414
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
[Bug]: RateLimitError() not working #2193
Comments
Another easy way to see the issue is to only add 1 job and look at the logs, you will see that it continues to run the job and throw the |
We created a complete repo here https://github.com/tmhao2005/bullmq-rate-limit |
hey @wootwoot1234 from your example I'm seeing that limiter.max option is missing in the worker config as we check if that value is present in order to do a rate limit validation for the next job keys. Seems like in our docs https://docs.bullmq.io/guide/rate-limiting#manual-rate-limit we were missing to add that option as in our test cases https://github.com/taskforcesh/bullmq/blob/master/tests/test_rate_limiter.ts#L360-L363 |
Thank you. I will try that.
…On Fri, Sep 22, 2023 at 10:10 PM Rogger Valverde ***@***.***> wrote:
hey @wootwoot1234 <https://github.com/wootwoot1234> from your example I'm
seeing that limiter.max option is missing in the worker config as we check
if that value is present in order to do a rate limit validation for the
next job keys. Seems like in our docs
https://docs.bullmq.io/guide/rate-limiting#manual-rate-limit we were
missing to add that option as in our test cases
https://github.com/taskforcesh/bullmq/blob/master/tests/test_rate_limiter.ts#L360-L363
—
Reply to this email directly, view it on GitHub
<#2193 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADGOGLQ5HDB3IQ5EW2Z2QLX3ZVNJANCNFSM6AAAAAA5DNBOPE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I've updated my code and the manual rate limiting is working but when the queue is manually rate-limited and delayed jobs should run, the jobs are not moved from |
I think it is expected that they go from delayed directly to active. We improved how delayed jobs are handled, so now they do not need to go back to wait and then move to active, they go directly. But this should not affect the rate limiting, is it doing so? |
The rate limiting seems to be working correctly now. I would prefer that
they go to `waiting` because I have checks in place that notify me if there
are too many jobs `waiting`. That way I'm notified if something is wrong
with the server, etc.
…On Mon, Sep 25, 2023 at 2:25 PM Manuel Astudillo ***@***.***> wrote:
I think it is expected that they go from delayed directly to active. We
improved how delayed jobs are handled, so now they do not need to go back
to wait and then move to active, they go directly. But this should not
affect the rate limiting, is it doing so?
—
Reply to this email directly, view it on GitHub
<#2193 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADGOGOS4I3BJDRIUDJLPOTX4HZDDANCNFSM6AAAAAA5DNBOPE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
hey @wootwoot1234, we are actually moving delayed jobs to wait, this is happening in the moveToActive script, but when the queue is rate limited, workers are not going to execute moveToActive, they are going to be in an idle state, then when the queue is not rate limited, workers will call moveToActive, this script promote delayed jobs (move them into wait state), but in the same script later we also move from wait to active, we only move 1 job to active, so the other promoted delayed jobs should be in wait or in prioritized state (if they have priority > 0) |
Does that mean that if we manually rate limit a queue for 10 seconds, after
10 seconds, all the jobs that would have run are moved to waiting, then
active but if we throw another 10 second manual rate limit, we will see a
bunch of jobs waiting? In other words, if the queue continues to be
manually rate limited the waiting jobs will continue to build, 10 seconds
at a time?
…On Mon, Sep 25, 2023 at 6:59 PM Rogger Valverde ***@***.***> wrote:
hey @wootwoot1234 <https://github.com/wootwoot1234>, we are actually
moving delayed jobs to wait, this is happening in the moveToActive script,
but when the queue is rate limited, workers are not going to execute
moveToActive, they are going to be in an idle state, then when the queue is
not rate limited, workers will call moveToActive, this script promote
delayed jobs (move them into wait state), but in the same script later we
also move from wait to active, we only move 1 job to active, so the other
promoted delayed jobs should be in wait or in prioritized state (if they
have priority > 0)
—
Reply to this email directly, view it on GitHub
<#2193 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADGOGJY7VXN74OVRNWXDTTX4IZJ5ANCNFSM6AAAAAA5DNBOPE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
hey @wootwoot1234, yes, delayed jobs will be moved to wait after those 10 seconds, this is happening because we will use those 10 seconds to postpone any job execution https://github.com/taskforcesh/bullmq/blob/master/src/classes/worker.ts#L486, after that time we will call moveToActive command that it's the one that moves delayed jobs to wait |
Version
4.11
Platform
NodeJS
What happened?
The rate limiter doesn't move jobs to
waiting
when theWorker.RateLimitError()
error is thrown. Even though theRateLimitError()
has been thrown, the jobs move fromdelayed
toactive
and continues to run jobs.How to reproduce.
Relevant log output
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: