rails/activejob/lib
Jean Boussier e922c59207 Implement Active Job enqueue_after_transaction_commit
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>
2024-04-03 16:32:16 +02:00
..
active_job Implement Active Job enqueue_after_transaction_commit 2024-04-03 16:32:16 +02:00
rails/generators/job s/the the /the / 2022-12-29 03:56:13 +09:00
active_job.rb Implement Active Job enqueue_after_transaction_commit 2024-04-03 16:32:16 +02:00