dimanche 6 novembre 2016

Race Condition Issues on ActiveRecord Serialized Column Rails

I have multiple rails server instances running all of them pointing to same db & this is done to handle bulk requests

Now Consider I have a column other_details in the car table, where it contains a serialized array of hashes like this,

[{some_info: false}, {some_info: true}]

Now what happens is if some request updates the first hash in the array to true in a request, the next request updates the other hash in the array to false but it retains the old value of first hash and updates, which causes a huge issue

How we can avoid this? What are the best practices, for tackling this kinda issues?

I'm using rails 3.2.22.2 and mysql

Aucun commentaire:

Enregistrer un commentaire