bull icon indicating copy to clipboard operation
bull copied to clipboard

Redis Cluster, Can't add the job to the failed queue

Open wdh-1025 opened this issue 3 years ago • 17 comments

In the environment of Redis cluster,Can't add the job to the failed queue,Job will hold the lock for a long time until the Job times out!

Description

queue.process('testjob', async (job,done) => {
     done(new Error('error transcoding'))
     //OR
     throw new Error('error transcoding')   
     //Can't add the job to the failed queue
})

Bull version

3.22.0

wdh-1025 avatar Mar 26 '21 02:03 wdh-1025

You must not use "done" and async at the same time in your process functions. Furthermore if you still have issues provide a complete reproducible case so we can look into it.

manast avatar Mar 26 '21 06:03 manast

Thanks for the reply, but this still doesn't seem to solve my confusion!

const bull = require('bull');

const queue = new bull('cluster', {
    prefix: '{test}',
    redis: {
        port: 6401,
        host: '127.0.0.1',
        password: 'He2jY9K3LNplLmbFS50i',
    },
    defaultJobOptions: {
        attempts: 3,     
        removeOnComplete: true,
        backoff: false
    },
    limiter: {   
        max: 1000,
        duration: 5000,
        bounceBack: true
    },
    settings: {
        maxStalledCount: 1,
        guardInterval: 3000,
        retryProcessDelay: 500
    }
})

queue.add('test', { event: 'access_token', target: 'public' } )

queue.process('test', (job,done) => {
    //Can't add the job to the failed queue
    done(new Error('test error'))
})

wdh-1025 avatar Mar 26 '21 06:03 wdh-1025

A couple of things, did this same example work in non cluster redis? and secondly, how do you know the job did not end in the failed status?

manast avatar Mar 26 '21 06:03 manast

It can work normally on non-cluster! The job holds the lock for a long time after the error is thrown, and it is not added to the failed queue until a long time later (job stalled more than allowable limit)

wdh-1025 avatar Mar 26 '21 07:03 wdh-1025

ok, then you need to define the prefix for the queue like this: "{myPrefix}", default is "bull" which is nt compatible with cluster: https://github.com/OptimalBits/bull/blob/develop/PATTERNS.md#redis-cluster

manast avatar Mar 26 '21 07:03 manast

As in the above case, I have defined the prefix, but still cannot achieve the expected effect,So I don't know if this is a framework compatibility issue. Is it possible to fix it in the future?

wdh-1025 avatar Mar 26 '21 07:03 wdh-1025

As in the above case, I have defined the prefix, but still cannot achieve the expected effect,So I don't know if this is a framework compatibility issue. Is it possible to fix it in the future?

oh yes sorry, I am blind this morning. What is your redis cluster setup?

manast avatar Mar 26 '21 07:03 manast

I am not quite sure what you mean, Because my Redis is a purchased cloud service. Redis Configuration(Redis 5.0 standard edition, dual copy, 2G cluster edition (2 shards))!

wdh-1025 avatar Mar 26 '21 07:03 wdh-1025

I need some setup in order to test it myself... is this in RedisLabs or where?

manast avatar Mar 26 '21 07:03 manast

The Redis service I purchased from ALiYun

wdh-1025 avatar Mar 26 '21 08:03 wdh-1025

Ok, I will try to reproduce this in a local setup. However, if you do not need the cluster setup for other things than Bull then you could also switch to non cluster mode, since there are no advantages in using cluster with Bull.

manast avatar Mar 26 '21 08:03 manast

Yes, but due to special reasons, I cannot switch to a non-clustered state. I look forward to making progress as soon as possible. Thanks again!

wdh-1025 avatar Mar 26 '21 08:03 wdh-1025

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jul 12 '21 13:07 stale[bot]

We're experiencing the same issue, I was wondering if this is planned to be fixed.

davidnazw avatar Jan 25 '22 08:01 davidnazw

@davidnazw first I need to be able to easily reproduce it, I haven't so far...

manast avatar Jan 25 '22 12:01 manast

Yes, but due to special reasons, I cannot switch to a non-clustered state. I look forward to making progress as soon as possible. Thanks again!

老哥 我也遇到同样的问题了 请问 你解决了吗?

zangguojun avatar Dec 04 '23 09:12 zangguojun

As a side note, you may consider upgrading to BullMQ -> https://bullmq.io as there are no know issues with Redis Cluster.

manast avatar Dec 04 '23 17:12 manast