Bull: Schedule Job fails - Missing lock for job

Created on 17 Dec 2019  路  2Comments  路  Source: OptimalBits/bull

I'm trying to add 2 scheduled repeating jobs like so :

await Minutely.add({ id: "go" }, {jobId : "Minutely" + new Date(), repeat: { cron: '*/5 * * * *' }})`

await Daily.add({ id: "go" }, { jobId : "Daily" + new Date(), repeat: { cron: '0 0 * * *' }, tz: 'UTC', timeout: 3600000, attempts : 1, backoff : 1 })

Both jobs added to the queue without an issue but when they run on their timings the Minutely Job runs fine...the Daily job always ends up in an error :

Missing lock for job repeat:4caf15418ba5f58ab4b3ed5f0a58ab9b:1576522800000 finished

Even though I have specified attemps and backoff it tries to run the job twice...

Here is what the daily job's OPTs look like

{
"repeat": {
"count": 3,
"cron": "0 0 * * *",
"jobId": "DailyMon Dec 16 2019 07:35:40 GMT+0500 (Pakistan Standard Time)"
},
"jobId": "repeat:4caf15418ba5f58ab4b3ed5f0a58ab9b:1576627200000",
"delay": 86399981,
"timestamp": 1576540800019,
"prevMillis": 1576627200000,
"tz": "UTC",
"timeout": 3600000,
"attempts": 1,
"backoff": {
"type": "fixed",
"delay": 1
}
}

I need a way to either limit the attempts to 1 or to make it work properly

Most helpful comment

  1. if you set unique jobid make sure both jobs are added only once to queue, bull won't deduplicate same jobs in this case
  2. this error means your job was stalled, try to increase lockDuration in queue constructor's settings parameter, from the docs:
Time in milliseconds to acquire the job lock. Set this to a higher value if you find that your jobs are being stalled because your job processor is CPU-intensive and blocking the event loop (see note below about stalled jobs).
  1. also try to set maxStalledCount to 0, due to specific implementation Bull can overwrite real error with useless Missing lock for job, and I hope this can help.

https://github.com/OptimalBits/bull/blob/develop/REFERENCE.md
Related issue #1416

For anyone looking for a solution - this worked like a charm

if you have a job that requires alot of processing time you need to configure it's QUEUE appropriately as mentioned above.

All 2 comments

1) if you set unique jobid make sure both jobs are added only once to queue, bull won't deduplicate same jobs in this case
2) this error means your job was stalled, try to increase lockDuration in queue constructor's settings parameter, from the docs:

Time in milliseconds to acquire the job lock. Set this to a higher value if you find that your jobs are being stalled because your job processor is CPU-intensive and blocking the event loop (see note below about stalled jobs).

3) also try to set maxStalledCount to 0, due to specific implementation Bull can overwrite real error with useless Missing lock for job, and I hope this can help.

https://github.com/OptimalBits/bull/blob/develop/REFERENCE.md
Related issue https://github.com/OptimalBits/bull/issues/1416

  1. if you set unique jobid make sure both jobs are added only once to queue, bull won't deduplicate same jobs in this case
  2. this error means your job was stalled, try to increase lockDuration in queue constructor's settings parameter, from the docs:
Time in milliseconds to acquire the job lock. Set this to a higher value if you find that your jobs are being stalled because your job processor is CPU-intensive and blocking the event loop (see note below about stalled jobs).
  1. also try to set maxStalledCount to 0, due to specific implementation Bull can overwrite real error with useless Missing lock for job, and I hope this can help.

https://github.com/OptimalBits/bull/blob/develop/REFERENCE.md
Related issue #1416

For anyone looking for a solution - this worked like a charm

if you have a job that requires alot of processing time you need to configure it's QUEUE appropriately as mentioned above.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alolis picture alolis  路  4Comments

chocof picture chocof  路  3Comments

sibelius picture sibelius  路  3Comments

weeco picture weeco  路  3Comments

pintocarlos picture pintocarlos  路  3Comments