I have a ruby on rails webapp hosted at digitalocean which stores its data on a mongo db through mongoID.
I'm importing some data through a common API on a sidekiq worker but then I try to create an object like:
array_of_consumptions = API.consumptions(id)
array_of_consumptions.each do |d|
user.array_of_consumptions << d
end
I can save this data on development locally, but it has random behaviours on production. For example, if I import 1000 consumptions my web app will probably save only 20 and there are no logs reporting problems.
I thought that this problem was related to sidekiq (even working ok locally) so I switched it to another one like resque but the problem remained. I check the validation of the saved objects and they are all valid after "saved".
Could this be related to transactions or problems on connections to mongodb?