Run it in background job, after commit, from Service Object
There is this problem that when you schedule a background job from inside of a running database transaction, the background job can kick in before the transaction is commited. Then the job can’t find the data that it expects to already be there, in database. How do we solve this issue? Let’s schedule the job from Service Object after db commit.
.
It also includes a small dive in into how Active Record tracks after_commit hooks.
Post a comment