On Wednesday, 24 October 2012 18:26:15 UTC-4, Filipe Giusti
wrote:>
> Hi fellow programmers,
>
> I was looking for how to keep integrity in some financial transactions and
> I saw this "This could even happen if you use transactions with the
> ‘serializable’ isolation level." in the uniqueness page
>
http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#method-i-validates_uniqueness_of.
> How this is possible with the serializablo isolation level? Aren''t
the
> select and update done in the same transaction?
>
>
They are, but that doesn''t prevent races like the one in the
documentation
from occurring - in that case, both transactions find no conflicting
records and create a row.
As noted in the docs, if you really really need data consistency you''re
better off using a unique index and catching ActiveRecord::RecordNotUnique.
--Matt Jones
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/78ImtEq69WAJ.
For more options, visit https://groups.google.com/groups/opt_out.