Heya - I'm running long-running jobs (jobTimeoutMs is set to 2 hours). When calling worker.close() to gracefully shutdown the worker, I've noticed that if there are a) jobs in progress and b) those jobs do not finish within gracefulTimeoutMs, then upon restart, the group lock will not be released and the job will stall. I see error messages like the following:
⚠️ Blocking found group but reserve failed: group=connection:1 (reserve took 1ms)
Here's a minimal example that can be used to reproduce the issue:
import{Queue,Worker}from'groupmq';importRedisfrom'ioredis';constQUEUE_NAME='repro-queue';constGROUP_ID='test-group';constredis=newRedis("redis://127.0.0.1:6379");constqueue=newQueue({
redis,namespace: QUEUE_NAME,jobTimeoutMs: 1000*60*5,logger: true});constworker=newWorker({
queue,handler: async(job)=>{console.log('Processing job',job.id);// Long running job (10 minutes)awaitnewPromise((resolve)=>setTimeout(resolve,1000*60*10))},logger: true});worker.run();process.on('SIGINT',async()=>{console.log('exiting...');// Graceful timeout less than the job durationawaitworker.close(5*1000);awaitqueue.close();process.exit(0);});constjob=awaitqueue.add({groupId: GROUP_ID,data: {}});console.log('Job added',job.id);Steps:
- Run the above script and wait till you see
Processing job ... in the console log - Interrupt the script with ctrl+c
- Start the script again
- You should see output such as the following:
⚠️ [groupmq:repro-queue] Blocking found group but reserve failed: group=test-group (reserve took 1ms)
⚠️ [repro-queue] STUCK WORKER ALERT: No activity for 180s
[repro-queue] 📊 Status Report:
[repro-queue] 🔢 Jobs Processed: 0
[repro-queue] ⏱️ Last Job: nevers ago
[repro-queue] 🚫 Consecutive Empty Reserves: 47
[repro-queue] 📞 Total Blocking Calls: 47
[repro-queue] 📈 Queue Stats: Active=1, Waiting=1, Delayed=0, Groups=test-group
[repro-queue] 🔄 Currently Processing: 0 jobs
[repro-queue] Fetching job (call #48, queue: 0/1)...
[groupmq:repro-queue] Starting blocking operation (timeout: 5s, consecutive empty: 0)
[groupmq:repro-queue] Blocking result: group=test-group, score=58779507660002 (took 1ms)
Heya - I'm running long-running jobs (
jobTimeoutMsis set to 2 hours). When callingworker.close()to gracefully shutdown the worker, I've noticed that if there are a) jobs in progress and b) those jobs do not finish withingracefulTimeoutMs, then upon restart, the group lock will not be released and the job will stall. I see error messages like the following:Here's a minimal example that can be used to reproduce the issue:
Steps:
Processing job ...in the console log