[Nitro] Og, serialized transactions?

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

From: "Judson Lester" <nyarly at gmail.com>
> On 2/22/07, Jonathan Buch <john at oxyliquit.de> wrote:
>> I'm not sure we can make MySQL thread safe (as I think the standard table
>> type doesn't react on 'transaction' anyway).  Maybe we put a ruby-level
>> synchronized around that part?
> Trouble is, when you have a db involved, process level locks aren't
> really enough. Slows down execution without real benefit.  This is why
> MySQL's eternal claim that transactions were unnecessary has always
> galled me.


On a related note, I'm wanting to use Og with postgres and 
have dozens of processes all interacting with the same

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.

I haven't tried this yet, but I'm hoping something like the
following would work:

  store = Playername.ogstore
  store.transaction {
    playername = Playername.find_or_create_by_playername("fred")

Am I on the right track here?  (I presume I'll have to deal
with catching an exception and retrying the transaction if
it fails.)



More information about the Nitro-general mailing list