My project consists of a machine that has clockwork, that creates new models in the DB.
I also have in the model after_create creating a sidekiq task using perform_async.
My problem is this: sporadically, when the sidekiq job starts, it queries for the model it was spawned for (if model X created a sidekiq job with parameter - X, sidekiq job queries for model with id X) - and it gets a nil!
how can that be? I am unable to trace what the problem is or what affects it.
after I retry the job it succeeds. - but it was made AFTER_CREATE so the model should already be committed to the DB.
Thanks for the help!
This question is answered in the FAQ wiki page. Use after_commit.