[Dbix-class] is it safe use find_or_create in "read committed" transaction level

Peter Rabbitson rabbit+dbic at rabbit.us
Mon Sep 20 13:04:30 GMT 2010


Bill Crawford wrote:
> On 20 September 2010 10:43, Peter Rabbitson <rabbit+dbic at rabbit.us> wrote:
> 
>> 1) We use a transaction the way we do now - depending on the isolation
> ...
>> 2) We issue the select with a read-lock. This however means that the
> ...
>> 3) We try to create the row first, going in blind. This is a good idea
>> in theory, however it has a nasty side effect that it makes the current
>> transaction no-longer-commitable. So using transactions in a race-prone
>> environment is out as well (the user sees random transactions failing
>> for no apparent reason)
> 
> Or you could 4) check whether savepoints are supported, use one, try
> the insert, and see what happens?

Savepoints do not help here. An error happening within a savepoint
invalidates *the entire transaction*. Test it on your RDBMS, but
I am pretty sure this is the case all-around.



More information about the DBIx-Class mailing list