aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-12-30 11:37:21 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2011-12-30 11:37:21 -0800
commit6769293988c0d7733138a562aaa683375cbdcb78 (patch)
treeaa367428777c10e792384b79e81a712785393722 /activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
parent7c55d6977c68041d34cb657f90f92773d3fd64e3 (diff)
downloadrails-6769293988c0d7733138a562aaa683375cbdcb78.tar.gz
rails-6769293988c0d7733138a562aaa683375cbdcb78.tar.bz2
rails-6769293988c0d7733138a562aaa683375cbdcb78.zip
connections must be checked in at the end of a thread
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb18
1 files changed, 1 insertions, 17 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 ea738cb305..0d8efa60c2 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -155,7 +155,6 @@ module ActiveRecord
# associated with stale threads.
def verify_active_connections! #:nodoc:
synchronize do
- clear_stale_cached_connections!
@connections.each do |connection|
connection.verify!
end
@@ -165,20 +164,8 @@ module ActiveRecord
# Return any checked-out connections back to the pool by threads that
# are no longer alive.
def clear_stale_cached_connections!
- keys = @reserved_connections.keys - Thread.list.find_all { |t|
- t.alive?
- }.map { |thread| thread.object_id }
- keys.each do |key|
- conn = @reserved_connections[key]
- ActiveSupport::Deprecation.warn(<<-eowarn) if conn.in_use?
-Database connections will not be closed automatically, please close your
-database connection at the end of the thread by calling `close` on your
-connection. For example: ActiveRecord::Base.connection.close
- eowarn
- checkin conn
- @reserved_connections.delete(key)
- end
end
+ deprecate :clear_stale_cached_connections!
# Check-out a database connection from the pool, indicating that you want
# to use it. You should call #checkin when you no longer need this.
@@ -214,12 +201,9 @@ connection. For example: ActiveRecord::Base.connection.close
return conn
end
- @queue.wait(@timeout)
-
if(active_connections.size < @connections.size)
next
else
- clear_stale_cached_connections!
if @size == active_connections.size
raise ConnectionTimeoutError, "could not obtain a database connection#{" within #{@timeout} seconds" if @timeout}. The max pool size is currently #{@size}; consider increasing it."
end