Standby::Base.inside_transaction? uses ActiveRecord::Base.connection on the primary to check whether access to the standby is occurring from within a transaction. ActiveRecord::Base.connection looks for a cached connection belonging to the current thread and, if it doesn't find one, attempts to checkout a connection from the connection pool. If the connection pool is exhausted, it blocks for up to ConnectionPool#checkout_timeout (default 5 seconds).
This change skips the transaction check if a connection has not been cached for the current thread. The assumption is there cannot be a current transaction without a current connection.
Also rename slavery_spec.rb to match renames done in d0e8c74019ef6278812dde662a8f27c897612c00.
https://github.com/kenn/standby/issues/36
Standby::Base.inside_transaction?
usesActiveRecord::Base.connection
on the primary to check whether access to the standby is occurring from within a transaction.ActiveRecord::Base.connection
looks for a cached connection belonging to the current thread and, if it doesn't find one, attempts to checkout a connection from the connection pool. If the connection pool is exhausted, it blocks for up toConnectionPool#checkout_timeout
(default 5 seconds).This change skips the transaction check if a connection has not been cached for the current thread. The assumption is there cannot be a current transaction without a current connection.
Also rename
slavery_spec.rb
to match renames done in d0e8c74019ef6278812dde662a8f27c897612c00.