instance method
reap
Ruby on Rails 7.0.10
Since v4.0.13Signature
reap()
Recover lost connections for the pool. A lost connection can occur if a programmer forgets to checkin a connection at the end of a thread or a thread dies unexpectedly.
Source
# File activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb, line 397
def reap
stale_connections = synchronize do
return if self.discarded?
@connections.select do |conn|
conn.in_use? && !conn.owner.alive?
end.each do |conn|
conn.steal!
end
end
stale_connections.each do |conn|
if conn.active?
conn.reset!
checkin conn
else
remove conn
end
end
end
Defined in activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb line 397
· View on GitHub
· Improve this page
· Find usages on GitHub