Reputation: 2148
I have a job that performs a state change, and the way I'm using it, the state is changed only after a certain amount of time has passed.
In my job class:
class ItemJob < ApplicationJob
queue_as :default
def perform(item)
item.do_this!
end
end
And it's being called from a model:
def create_item_worker
ItemJob.set(wait: 30.seconds).perform_later(self)
end
However this is not working because ActiveJob has a queue of jobs for records that no longer exist. I type bundle exec sidekiq
into Terminal and it spits out crap like ActiveJob::DeserializationError: Error while trying to deserialize arguments: Couldn't find Item with 'id'=67
.
So how do I clear that? Sidekiq::Queue.all.each(&:clear)
doesn't seem to do anything.
Upvotes: 0
Views: 3460
Reputation: 22228
Your job is not enqueued anymore since it failed, it is waiting in the retry set to be re-enqueued at a later time. You want Sidekiq::RetrySet.new.clear
.
Please read the API and Error Handling wiki pages to learn more.
https://github.com/mperham/sidekiq/wiki/API
Upvotes: 7