e922c59207
A fairly common mistake with Rails is to enqueue a job from inside a transaction, with a record as argumemnt, which then lead to a RecordNotFound error when picked up by the queue. This is even one of the arguments advanced for job runners backed by the database such as `solid_queue`, `delayed_job` or `good_job`. But relying on this is undesirable in my opinion as it makes the Active Job abstraction leaky, and if in the future you need to migrate to another backend or even just move the queue to a separate database, you may experience a lot of race conditions of the sort. To resolve this problem globally, we can make Active Job optionally transaction aware, and automatically defer job queueing to `after_commit`. Co-Authored-By: Cristian Bica <cristian.bica@gmail.com> |
||
---|---|---|
.. | ||
active_job | ||
rails/generators/job | ||
active_job.rb |