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-02-04 15:54:32 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2011-02-04 18:14:59 -0800
commitacccb72cb12ab55bb01c3dce32f54f4a59ebec6c (patch)
tree8c4cc3cea1336efc12e242a0d6bf4ba18e5a9434 /activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
parentc94651f8c822f7c0778c03eb36bee5ca19f35911 (diff)
downloadrails-acccb72cb12ab55bb01c3dce32f54f4a59ebec6c.tar.gz
rails-acccb72cb12ab55bb01c3dce32f54f4a59ebec6c.tar.bz2
rails-acccb72cb12ab55bb01c3dce32f54f4a59ebec6c.zip
column cache now lives on the connection pool
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.rb6
1 files changed, 5 insertions, 1 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 63cdce5e4d..b9bfad2bd1 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -57,6 +57,7 @@ module ActiveRecord
# * +wait_timeout+: number of seconds to block and wait for a connection
# before giving up and raising a timeout error (default 5 seconds).
class ConnectionPool
+ attr_accessor :automatic_reconnect
attr_reader :spec, :connections
attr_reader :columns, :columns_hash, :primary_keys
@@ -82,6 +83,7 @@ module ActiveRecord
@connections = []
@checked_out = []
+ @automatic_reconnect = true
@columns = Hash.new do |h, table_name|
h[table_name] = with_connection do |conn|
@@ -281,6 +283,8 @@ module ActiveRecord
end
def checkout_new_connection
+ raise ConnectionNotEstablished unless @automatic_reconnect
+
c = new_connection
@connections << c
checkout_and_verify(c)
@@ -379,7 +383,7 @@ module ActiveRecord
pool = @connection_pools[klass.name]
return nil unless pool
- @connection_pools.delete_if { |key, value| value == pool }
+ pool.automatic_reconnect = false
pool.disconnect!
pool.spec.config
end