You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Any ActiveRecord call afterwards will use the next connection in the pool which does not have a transaction.
When DatabaseCleaner closes the transaction, it will only do so on the next active connection. Thus leaving a connection with an active transaction in the connection pool which can deadlock when doing a deletion cleanup or any table modifications.
DatabaseCleaner should start and end transactions the same way ActiveRecord does by collecting all available connections and starting transactions on all of them.
The text was updated successfully, but these errors were encountered:
ryanong
changed the title
DatabaseCleaner improperly starts and ends transactions
DatabaseCleaner improperly starts and ends transactions for ActiveRecord
Sep 19, 2014
If there is more than one connection in the connection pool DatabaseCleaner will only begin the transaction on one of the connections.
https://github.com/rails/rails/blob/master/activerecord/lib/active_record/fixtures.rb#L979
Any ActiveRecord call afterwards will use the next connection in the pool which does not have a transaction.
When DatabaseCleaner closes the transaction, it will only do so on the next active connection. Thus leaving a connection with an active transaction in the connection pool which can deadlock when doing a deletion cleanup or any table modifications.
DatabaseCleaner should start and end transactions the same way ActiveRecord does by collecting all available connections and starting transactions on all of them.
start: https://github.com/rails/rails/blob/06a9e18e646845ded0f0a46a14c1eb6b3a14e55a/activerecord/lib/active_record/fixtures.rb#L949
end: https://github.com/rails/rails/blob/06a9e18e646845ded0f0a46a14c1eb6b3a14e55a/activerecord/lib/active_record/fixtures.rb#L967
The text was updated successfully, but these errors were encountered: