def available_read_connections
available = @available_read_connections.last
if available.expired?
begin
@logger.info("Adding dead database connection back to the pool") if @logger
available.reconnect!
rescue => e
if @logger
@logger.warn("Failed to reconnect to database when adding connection back to the pool")
@logger.warn(e)
end
available.expires = 30.seconds.from_now
return available.connections
end
@available_read_connections.pop
return available_read_connections
else
return available.connections
end
end