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
Removing active/running jobs #473
Comments
The code seems to be correct. If you can write a test case that fails I can look into it. |
Ok will do |
It's strange that i tried to release the lock, then delete, but shows errors in my stacktrace [queue-manager-1]2017-03-30T05:56:25.229464043Z Unhandled rejection Error: Could not get lock for job: 3ebadf00-14c0-11e7-b2b5-91515b0b1873. Cannot remove job.
[queue-manager-1]2017-03-30T05:56:25.229507753Z at /usr/src/app/node_modules/bull/lib/job.js:316:13
[queue-manager-1]2017-03-30T05:56:25.229518898Z at tryCatcher (/usr/src/app/node_modules/bluebird/js/release/util.js:16:23)
[queue-manager-1]2017-03-30T05:56:25.229527773Z at Promise._settlePromiseFromHandler (/usr/src/app/node_modules/bluebird/js/release/promise.js:510:31)
[queue-manager-1]2017-03-30T05:56:25.229537154Z at Promise._settlePromise (/usr/src/app/node_modules/bluebird/js/release/promise.js:567:18)
[queue-manager-1]2017-03-30T05:56:25.229548847Z at Promise._settlePromise0 (/usr/src/app/node_modules/bluebird/js/release/promise.js:612:10)
[queue-manager-1]2017-03-30T05:56:25.229555024Z at Promise._settlePromises (/usr/src/app/node_modules/bluebird/js/release/promise.js:691:18)
[queue-manager-1]2017-03-30T05:56:25.229559872Z at Promise._fulfill (/usr/src/app/node_modules/bluebird/js/release/promise.js:636:18) |
Does this happens all the time? since releasing the lock and then removing is not performed atomically, there may be another worker trying to lock the job during that small window. In which context are you tying to remove the jobs? |
yea seems to happen all the time for me. I am trying to remove a running job. What happens is there are long running jobs that might get stuck without returning a status, I wrote the above code to allow developers to kill the active job to free the queue. |
why don't you try job.moveToFailed instead? You can use it giving it a reason as well: job.moveToFailed(Error('job has been stuck for too long')) It seems that the feature that you would like to have is some kind of TTL, where if a job takes more than the given time it is failed automatically. I will consider it for an upcoming release. |
Feature request: #479 |
I do realize that then I moveToFailed, the queue doesn't automatically start pending jobs, is this expected behavior ? |
Please any update on removing all jobs? |
One way to do this is that you could spawn child processes from your main process that implement const execa = require("execa");
let filePath = path.join(__dirname, "./worker.js");
worker = execa(`node`, filePath);
// kill job
worker.kill(); |
A simple way of cleaning all queues, freeing them from all jobs is to use following class:
|
Tried using the following to remove an active job. Is there a better way to do this ? I am still seeing the job in redis
The text was updated successfully, but these errors were encountered: