Clears the cache which maps classes and re-connects connections that
require reloading.
Raises:
ActiveRecord::ExclusiveConnectionTimeoutError
if unable to gain ownership of all connections in the pool within a timeout
interval (default duration is spec.config[:checkout_timeout] * 2
seconds).
# File activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb, line 444
def clear_reloadable_connections(raise_on_acquisition_timeout = true)
num_new_conns_required = 0
with_exclusively_acquired_all_connections(raise_on_acquisition_timeout) do
synchronize do
@connections.each do |conn|
checkin conn
conn.disconnect! if conn.requires_reloading?
end
@connections.delete_if(&:requires_reloading?)
@available.clear
if @connections.size < @size
# because of the pruning done by this method, we might be running
# low on connections, while threads stuck in queue are helpless
# (not being able to establish new connections for themselves),
# see also more detailed explanation in +remove+
num_new_conns_required = num_waiting_in_queue - @connections.size
end
@connections.each do |conn|
@available.add conn
end
end
end
bulk_make_new_connections(num_new_conns_required) if num_new_conns_required > 0
end