Forum: Ruby on Rails Uniqueness and sql serialize

Posted by Filipe Giusti (Guest)
on 2012-10-25 11:50
(Received via mailing list)
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/Va....
How this is possible with the serializablo isolation level? Aren't the
select and update done in the same transaction?
Posted by Matt Jones (Guest)
on 2012-10-26 14:22
(Received via mailing list)
On Wednesday, 24 October 2012 18:26:15 UTC-4, Filipe Giusti wrote:
>
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
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.