-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Error: Could not remove job #1098
Comments
you cannot remove a job while it is being processed, a job is in the active state and locked until it either: completes, fails or stales, although it should never stale if using a sandbox processor in practice. |
@manast , thanks for getting back to me. Isn't there some workaround I can do without destroying the library? I find it very strange that nobody has requested this functionality! Any suggestion would be great since this is a must for my service :( Can I force fail it somehow and then remove it? I would expect this to work but it didn't:
Also, I recommend to update the docs if you are planning to leave it as it is since it's not clear that this is intended or maybe change the error to be more descriptive. |
I tried to do the following which indeed removes the job from Redis but does not kill the processor process (makes sense if
I didn't like it anyway because I do not want to mess with the locks. The only way to do this probably is to signal via Redis pub/sub events the processor and |
We have some discussion regarding aborting jobs here: #114 |
@manast thanks for getting back to me. That discussion is going on since 2015 from what I checked so it's not very promising :) Last night I had a quick look at what's going on with cancel and I did the following change as an experiment:
Do you think you can provide me an alternative which might be better? The above however does not cover handlers that are not sandboxed. I think this should be done in I do not mind changing my fork and using that for now in order to have abort functionality but I must really implement something so I can complete the project I am doing so please, if you have a better suggestion I am all ears, even if its a bit ugly! Not sure if you are interested in this but I pushed a PR anyway #1105 |
Unfortunately I have quite a log of workload right now so I could not say when I can implement such a feature. Although I think the right approach is exactly the one you are pursuing, i.e. a cancel mechanism inspired in promise cancellation. |
@manast i understand although I wasn't expecting a feature implementation at this point, just your thoughts on how to solve it, temporarily at least on my side. I did solve it yesterday with the sandbox approach I described above but it also required a change in the Queue class. The complete code I am now using, in combination with the refactored sandbox is the following:
If you look above, i keep track of the job promises inside the |
@alolis When you have a chance, mind sharing how you used the above? Also can't believe no one else has asked to abort a job! |
@simpleshadow aborting a job at the end of the day will require your process function to be prepared for it, so basically you could also implement some signalling mechanism to your process function so that your code can fail the process earlier. All in all, a hard problem to solve but we are working on a more integrated solution. |
@simpleshadow , it has been a major pain point for my use case unfortunately, along with this. I came up with two solutions for the abort based on the current design of Both solutions require you to extend the SOLUTION 1Overview:Although When a job is removed, a custom The advantage of this solution is that NO changes are required to the bull library (except a small bug I found and it wont allow this solution to work but I will submit a PR for it soon and provide more info at the end of this post) and by extending a couple of classes, the limitation can be overcome. Problems
Code
Example Usage
SOLUTION 2Overview:Use the I had to use my own fork in order to achieve this solution. The only changes that are required can be found here: Problems
Code
Example Usage
The appropriate solutionIn my opinion the correct solution to the whole issue is to allow attaching optional hooks to the processor by changing the processor signature to:
And then you will be able to do things like:
The processor will have the chance to do a graceful shutdown before exiting or even better, throwing a The above also allows to be extended by providing If no hooks are provided then the process should be forced killed and moved to failed with 'cancelled' failed reason. Bug in
|
Thank you for all your work and detail @alolis. I ended up attempting to use Bull for its queue and handled forking and killing processes outside of Bull accordingly. When a job would need to be aborted, the job's forked process would be killed and the its The disconnect between the queue jobs and forked processes is concerning and will require a bit more testing, but I think satisfactory for my use case. I'll try using your examples in the coming days and let you know if they work out better for me. Thanks again. |
@simpleshadow, can you share some more details? Are you storing the forked process pid somewhere in order to kill the process afterwards or did you mean that you are forking the process yourself? How does the whole thing works exactly? I will be waiting for your feedback as well :) |
@alolis @simpleshadow I'm curious if you ever found cleaner ways to achieve this? |
@kzidane I haven't had the time to do something else other than what I described above. For the problem to be solved properly the fix must be done in the core library. |
…cess-fix1098 fix: remove broken child processes fix #1098
Any chance this feature is still on the cards? |
any work on this yet? |
@alolis would you be able to update your fork with latest changes in bull merged with your updates? |
Description
I am experiencing the following error whenever I try to remove a job:
Minimal, Working Test code to reproduce the issue.
I am using the sandboxed environment and the issue is reproducible even with a simple processor like so:
Bull version
I am using Node.js v6.9.1 with bull v3.4.8 and redis-server v3.0.7
Also by looking at this I understand that I can remove jobs while in progress. Is this true? What is the correct way to force remove a job if indeed true?
Thank you for your time.
The text was updated successfully, but these errors were encountered: