Forum: Ruby on Rails ActiveRecord transactions & thread safety

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
870d77abc648ef1299376071e8471455?d=identicon&s=25 Alexey Chernenkov (Guest)
on 2014-06-03 06:34
(Received via mailing list)
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!
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2014-06-03 09:13
(Received via mailing list)
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 topic is locked and can not be replied to.