[Nitro] Og, serialized transactions?

Bill Kelly billk at cts.com
Sat Feb 24 20:59:24 EST 2007

From: "Reid Thompson" <reid.thompson at ateb.com>
> On 13:59 Sat 24 Feb     , Bill Kelly wrote:
>> If several processes all happened to do a find_or_create
>> at the same time with the same name:
>>   playername = Playername.find_or_create_by_playername("fred")
>> ...I'm concerned about how to eliminate the possibility of
>> a race condition where I could end up with more than one
>> "fred" player record being created.
> make playername unique - return an approprite response to the process
> that attempts to create a duplicate player, and handle it
> appropriately.

Ah.  Makes sense.  But I wonder how the error will be
reported?  I suppose find_or_create might raise an exception?
Or maybe the exception could happen when my transaction

(I looked at how find_or_create_by_ works... very ingenious
use of split and zip... :)

Regarding the use of "unique", I also have a more complex
scenario, which would require a multi-column unique constraint:

class PlayerSeen
  property :first_seen, Time
  property :last_seen, Time
  property :times_seen, Integer
  refers_to :iphost, IPHost          # \
  refers_to :playername, Playername  #  - multi-column unique
  refers_to :servername, Servername  # /

playerseen = PlayerSeen.find_or_create_by_iphost_oid_and_playername_oid_and_servername_oid(iphost.oid, playername.oid, 


CREATE UNIQUE INDEX playerseen_unique ON PlayerSeen.table_name
(iphost_oid, playername_oid, servername_oid);

Is it possible to specify a multi-column unique constraint in Og?



More information about the Nitro-general mailing list