diff options
author | Nick Sieger <nick@nicksieger.com> | 2008-08-22 13:45:10 -0500 |
---|---|---|
committer | Nick Sieger <nick@nicksieger.com> | 2008-08-29 14:12:12 -0500 |
commit | 212134dce158db0ecb4169c28fd9ef80ea1a55b2 (patch) | |
tree | f9028fe87def283d1fd46dd457015eae465842d5 /activerecord/lib/active_record/connection_adapters/abstract | |
parent | ca6d71753f3a2e8a0a29108b7c55ba3b7c8cd943 (diff) | |
download | rails-212134dce158db0ecb4169c28fd9ef80ea1a55b2.tar.gz rails-212134dce158db0ecb4169c28fd9ef80ea1a55b2.tar.bz2 rails-212134dce158db0ecb4169c28fd9ef80ea1a55b2.zip |
Remove CachedConnectionPerThread per-thread pooling mechanism in favor of a fixed pool with default maximum of 5 connections
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb | 21 |
1 files changed, 4 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 04c8361c64..1b908c3113 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb @@ -36,12 +36,10 @@ module ActiveRecord # * +wait_timeout+ (optional): number of seconds to block and wait # for a connection before giving up and raising a timeout error. def self.create(spec) - if spec.config[:pool] && spec.config[:pool].to_i > 0 - FixedSizeConnectionPool.new(spec) - elsif spec.config[:jndi] # JRuby appserver datasource pool; passthrough + if spec.config[:jndi] # JRuby appserver datasource pool; passthrough NewConnectionEveryTime.new(spec) else - CachedConnectionPerThread.new(spec) + FixedSizeConnectionPool.new(spec) end end @@ -204,18 +202,6 @@ module ActiveRecord end end - # CachedConnectionPerThread is a compatible pseudo-connection pool that - # caches connections per-thread. In order to hold onto threads in the same - # manner as ActiveRecord 2.1 and earlier, it only disconnects the - # connection when the connection is checked in, or when calling - # ActiveRecord::Base.clear_all_connections!, and not during - # #release_connection. - class CachedConnectionPerThread < NewConnectionEveryTime - def release_connection - # no-op; keep the connection - end - end - # FixedSizeConnectionPool provides a full, fixed-size connection pool with # timed waits when the pool is exhausted. class FixedSizeConnectionPool < ConnectionPool @@ -223,7 +209,8 @@ module ActiveRecord super # default 5 second timeout @timeout = spec.config[:wait_timeout] || 5 - @size = spec.config[:pool].to_i + # default max pool size to 5 + @size = (spec.config[:pool] && spec.config[:pool].to_i) || 5 @queue = @connection_mutex.new_cond @connections = [] @checked_out = [] |