1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

use connect_poll on pg so that reaping does not hurt the connection

This commit is contained in:
Aaron Patterson 2013-03-20 11:21:13 -07:00
parent 7150a9dc03
commit 34c7e73c1d
2 changed files with 4 additions and 3 deletions

View file

@ -406,7 +406,9 @@ module ActiveRecord
synchronize do
stale = Time.now - @dead_connection_timeout
connections.dup.each do |conn|
remove conn if conn.in_use? && stale > conn.last_use && !conn.active?
if conn.in_use? && stale > conn.last_use && !conn.active?
remove conn
end
end
end
end

View file

@ -519,8 +519,7 @@ module ActiveRecord
# Is this connection alive and ready for queries?
def active?
@connection.query 'SELECT 1'
true
@connection.connect_poll != PG::PGRES_POLLING_FAILED
rescue PGError
false
end