Hi All,

I apologize in advance if this isn't on topic, but I've had success with 
general rails questions here before, so here goes:

We are going to add some pessimistic locking to a DelayedJob that we are 
running.  The code appears easy enough (this is rails2):

  User.transation do
    user = User.find( id, :lock => true )

    # some tragically complicated code

  end

The code that will be run within the transaction is non-trivial.  I'm going 
to try to shave it down to the minimal amount but, unfortunately, we need 
to do a read early on to establish some data for a series of calculations, 
so it isn't possible to make the code totally trivial.

Here are my questions:


   - Will the transaction (and row lock) unroll if an exception occurs (I 
   have to assume so, given the API)
   - If all hell breaks loose and we manage to lock a row and not unlock it 
   (e.g. an infinite loop in the DelayedJob body) would my only option to be 
   to restart the database?  What's the command to do that on heroku?
   - Is there any other way I could leave the row locked beyond an infinite 
   loop in the code within the transaction?  My hope is that the transaction 
   API guarantees the lock is released once you exit the block
   - What questions *should* I be asking? 

Thanks for any help and advice,
Carson

-- 
You received this message because you are subscribed to the Google
Groups "Heroku" group.

To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/heroku?hl=en_US?hl=en

Reply via email to