diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-03-20 11:21:13 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-03-20 11:21:13 -0700 |
commit | 34c7e73c1def1312e59ef1f334586ff2f668246e (patch) | |
tree | 8206387c82d74e37f11b0619a14048417741e0bd /activerecord/lib | |
parent | 7150a9dc036ca02e8293d31ac57a26c55860fff7 (diff) | |
download | rails-34c7e73c1def1312e59ef1f334586ff2f668246e.tar.gz rails-34c7e73c1def1312e59ef1f334586ff2f668246e.tar.bz2 rails-34c7e73c1def1312e59ef1f334586ff2f668246e.zip |
use `connect_poll` on pg so that reaping does not hurt the connection
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb | 4 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 3 |
2 files changed, 4 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb index 1754e424b8..bf2f945448 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb @@ -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 diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index dfa4c3967a..940de7e4f6 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -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 |