Uniqueness and sql serialize

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
ActiveRecord::Validations::ClassMethods.
How this is possible with the serializablo isolation level? Aren’t the
select and update done in the same transaction?

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 J.