ActiveRecord transactions & thread safety

My question is about AR transactions feature. Is it thread safe?
Is it safe to use both *ActiveRecord::Base.transaction do ...* and
*Account.transaction do ...* statements?

I plan to use Puma as web server, and Sidekiq for background processing.
Is there some tricks I should know about?

Thanks!

On Tuesday, June 3, 2014 5:32:57 AM UTC+1, Alexey Chernenkov wrote:

My question is about AR transactions feature. Is it thread safe?
Is it safe to use both ActiveRecord::Base.transaction do ... and
Account.transaction do ... statements?

It should be - a connection is only ever used by 1 thread at a time (and
unless you have configured Account to use a separate connection then AR
won’t be default create nested transactions/save points )If you could
show in more detail what you are doing then a more considered reply
might be possible.

Fred

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs