From: Jess Robinson Date: Thu, 24 Jul 2008 06:58:45 +0000 (+0000) Subject: Added doc patch about race condition in find_or_create from MNDRIX X-Git-Tag: v0.08240~392 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=50c4adf9c88c7f842e6790fe78a1f4e290c59054;p=dbsrgits%2FDBIx-Class.git Added doc patch about race condition in find_or_create from MNDRIX --- diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index be7d6be..50bbc10 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -1751,6 +1751,12 @@ constraint. For example: { key => 'cd_artist_title' } ); +Note: Because find_or_create() reads from the database and then +possibly inserts based on the result, this method is subject to a race +condition. Another process could create a record in the table after +the find has completed and before the create has started. To avoid +this problem, use find_or_create() inside a transaction. + See also L and L. For information on how to declare unique constraints, see L.