0
votes

Lets say I have this sidekiq worker:

  def perform post_id
    post = Post.find post_id
    post.do_something
  end

What would happen if the post was not found and an exception was raised?

Will sidekiq try again?

What would be a better design so that sidekiq would not try again without using sidekiq_options :retry => false

Thanks!

1

1 Answers

1
votes

If you don't want an exception raised, use find_by_id instead, which returns nil if the record doesn't exist, rather than raising an exception. Be sure to check for nil, though:

def perform post_id
  post = Post.find_by_id post_id
  post.do_something if post
end