How to prevent "Error: Missing lock for job ___", how to add an event listener (docs wrong) #1912
Replies: 2 comments 8 replies
-
hi @GeoffreyPlitt, from https://docs.bullmq.io/guide/events you can see some examples but it does mean that all events will handle the same parameters. I think that what you are looking for is WorkerListerner api reference https://api.docs.bullmq.io/interfaces/WorkerListener.html#stalled. What we can do is add Listeners references at the bottom in Read more section |
Beta Was this translation helpful? Give feedback.
-
I am confused by this explanation. The error you are getting is usually caused when a different worker is trying to complete (or fail) a job that has already been completed or failed OR a job that has stalled and moved back to wait. None of these situations are "normal", they can happen but if they happen often then something is not working correctly in your code. It could be that the jobs are locking the event loop, in that case, you should find strategies to avoid this locking or enable worker threads (with a concurrency lower than the number of CPUs). https://docs.bullmq.io/guide/workers/sandboxed-processors#worker-threads |
Beta Was this translation helpful? Give feedback.
-
Node 14.21.3
BullMQ 3.10.2
Our company uses BullMQ and we noticed logs saying "Error: Missing lock for job ___". I understand in theory what this means and how to fix it, but I'm having trouble with the specifics.
The problem happens because the job takes longer than allowed (we aren't using updateProgress yet) so it gets retried, but then the original job finally succeeds and tries to update the status to successful, but can't because the system moved on and retries it elsewhere. I get that. Our job is idempotent so there isn't a big problem with the behavior, but I'd like to remove the noise in the logs and display this situation more effectively.
Question: Will subscribing to the "stalled" event prevent this error from printing? I'll assume yes for the rest of this post, but it isn't clear to me from the docs.
When I go to subscribe to the "stalled" event, I'm following the docs at https://docs.bullmq.io/guide/events; however I think the docs are out of date because typescript says the parameters are wrong when I try that:
Trying to understand how to fix this, I look at the source, which says on() takes a queue listener...
I can't find QueueListener in the source, except in a gitbook:
https://github.com/taskforcesh/bullmq/blob/master/docs/gitbook/api/bullmq.queuelistener.md
Which does not explain the params for a successful event listener.
Are there examples of event listeners out there that work? Was I looking in the wrong places to find them?
Beta Was this translation helpful? Give feedback.
All reactions