Skip to content
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

Anya/375 sikekiq not found #498

Merged
merged 5 commits into from
Jun 19, 2017
Merged

Anya/375 sikekiq not found #498

merged 5 commits into from
Jun 19, 2017

Conversation

anyakhvost
Copy link
Contributor

connects #375

  1. Record not found issue - Sidekiq is finding out about the job before the database record has it committed, so use after_commit on: :create.
  2. Add test_after_commit gem to actually test after_commit hook in rspec.

@amprokop
Copy link
Contributor

@aroltsch — can we add a little bit of context on how this connects to #375 ? is there a recommended way we can test that this addresses the issue/how did you discover the fix?

@@ -40,6 +40,10 @@ class Download < ActiveRecord::Base
end
end

# Sidekiq is finding out about the job before the database record has it committed,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this verb tense may not clearly show the meaning after this is merged.

Suggest something more like To prevent Sidekiq from finding out...

And maybe we can post that SO link too?

@anyakhvost
Copy link
Contributor Author

@amprokop
I think here is what happens: Active Record starts to create a download in the DB. Then immediately we fire up the Sidekiq job to use that download record. The Sidekiq job is a separate process so it cannot use the same in-memory download from the rails application so it goes to the DB to look for it. When it goes to look for it, the download record is not committed yet in the DB so it fails to find the record. Hence we get these logs:
Record not found... Exception ActiveRecord::RecordNotFound: Couldn't find Download with 'id'=xxx
The fix is to fire up the Sidekiq job after the record has been committed to the DB.
The issue was happening randomly so in order to test it, the QA person would need to try a bunch of downloads and see if it happens again.

@anyakhvost anyakhvost merged commit 89848cf into master Jun 19, 2017
@anyakhvost anyakhvost deleted the anya/375_sikekiw_not_found branch June 19, 2017 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants