-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting ActiveRecord::RecordNotFound from time to time when using Sidekiq #95
Comments
I have no idea what the problem might be. |
I've seen this in production in a few apps, my best guess is that Sidekiq is picking up the job before the transaction has completed. Adding a delay of a few seconds has fixed it in every case I've come across. |
@KazW The real question is how. We can clearly see after_commit block is used. That means Sidekiq is either faster than light, or after_commit doesn't happen after the commit. |
Ah, I've only used this with Devise 3.x when it was after_save... Nevermind! |
No resolution on this then? We're experiencing this with other Sidekiq jobs. Does anybody know of a way to simulate this in a test environment (we're specifically using Postgres)? We have some linear code that basically goes some_model = SomeModel.create!(...)
SomeAsyncService.new.perform(some_model) The service kicks off a Sidekiq Job, which picks up the job (impressively) before the model is committed (despite a proper primary key being set etc). |
@voltechs No resolution, unfortunately. Given Sidekiq cannot be faster than light, after_commit must happen technically after a commit but before the result of that commit is available to database clients. |
I can clearly see after_commit being used in the code:
Yet, ActiveRecord::RecordNotFound still happens from time to time.
Any ideas how to fix it, @mperham?
The text was updated successfully, but these errors were encountered: