I'm using Resque on a rails-3 project to handle jobs that are scheduled to run every 5 minutes. I recently did something that snowballed the creation of these jobs and the stack has hit over 1000 jobs. I fixed the issue that caused that many jobs to be queued and now the problem I have is that the jobs created by the bug are still there and therefore It becomes difficult to test something since a job is added to a queue with 1000+ jobs. I can't seem to stop these jobs. I have tried removing the queue from the redis-cli using the flushall command but it didn't work. Am I missing something? coz I can't seem to find a way of getting rid of these jobs.
相关问题
- Eager-loading association count with Arel (Rails 3
- Getting Redis Master address from Sentinel C#
- Configuring Redis to play nice with AppHarbor
- Create scheduled task using Task Scheduler Managed
- Using task scheduler for running java jar (from ba
Resque already has a method for doing this - try
Resque.remove_queue(queue_name)
(see the documentation here). Internally it performsResque.redis.del()
, but it also does other cleanup, and by using an api method (rather than making assumptions about how resque works) you'll be more future-proof.Updated rake task for clearing (according to latest redis commands changes): https://gist.github.com/1228863
This is what works now:
Playing off of the above answers, if you need to clear all of your queues, you could use the following:
Enter redis console:
List databases:
"resque:queue:your_overloaded_queue"
- db which you need.Then run:
Or if you want to delete specified jobs in queue then list few values from db with
LRANGE
command:Then copy/paste one value to
LREM
command:Where 5 - number of elements to remove.
It's safer and bulletproof to use the Resque API rather than deleting everything on the Resque's Redis. Resque does some cleaning in the inside.
If you want to remove all queues and associated enqueued jobs:
The queues will be re-created the next time a job is enqueued.
Documentation