Hi. I'm well aware of the RecordNotFound errors and how to avoid them. However, I'm getting a case where the record has been in existence for a long long time. I have the following worker:
class SetBatchWorker
include Sidekiq::Worker
def perform(student_id,
current_batch_id,
new_batch_id,
has_grades,
background_job_id = nil)
ActiveRecord::Base.transaction do
# I'm getting a `RecordNotFound` error here
student = Student.includes(:batches_students).find(student_id)
# I'm gonna omit the code present here, as it's not relevant to this issue
end
end
end
I can guarantee that every time this code fails (which is not always), a student with the submitted id exists and has existed for a long time (days, even months) before calling the perform method.
This makes absolutely no sense to me, and this error never happened with Resque.
In any case, my app also is suffering from errors that occur when not using after_commit or scheduling, except that I'm actually using after_commit and perform_in(60.seconds). Suspiciously, when the job gets scheduled, I quickly open a Rails console and look for a record that might cause the RecordNotFound exception, and, yes, at all times, those records exists. However, when the job gets executed it fails not finding the record, even when I just myself found it seconds ago!
I am having exactly the same issue and it's driving me crazy
Hello. After hours and hours of investigation, I've found that this issue is not caused by Sidekiq.
In my case (I can't speak for anyone else), I had 3 Elastic Beanstalk applications which were sharing the same redis server. While these applications had the same code and redis server, they had different databases, which meant that when one job had to be processed, one of the applications took the job and executed it. As one would expect, if the application which submitted the job to redis was different than the one which executed it, of course a lot of records weren't found, because they were in another database.
To fixed it, I added a namespace option to redis in the sidekiq configuration, like this:
config.redis = {
url: ENV['REDIS_URL'],
namespace: "some_namespace_different_for_each_app"
}
I'm closing this issue
Most helpful comment
Hello. After hours and hours of investigation, I've found that this issue is not caused by Sidekiq.
In my case (I can't speak for anyone else), I had 3 Elastic Beanstalk applications which were sharing the same redis server. While these applications had the same code and redis server, they had different databases, which meant that when one job had to be processed, one of the applications took the job and executed it. As one would expect, if the application which submitted the job to redis was different than the one which executed it, of course a lot of records weren't found, because they were in another database.
To fixed it, I added a namespace option to redis in the sidekiq configuration, like this:
I'm closing this issue