diff options
author | Aliaksey Kandratsenka <alk@tut.by> | 2008-10-02 22:59:49 +0300 |
---|---|---|
committer | Michael Koziarski <michael@koziarski.com> | 2008-10-04 17:48:13 +0200 |
commit | 834361145a805b5077f962dc2e67a0a9ea882535 (patch) | |
tree | ca7b7005a3fbe97fb4031ef44320ffb84f721c2c /activerecord/lib/active_record | |
parent | 21eb18a70c7a1f08e7e2dc1c5bc17d67e1d14c46 (diff) | |
download | rails-834361145a805b5077f962dc2e67a0a9ea882535.tar.gz rails-834361145a805b5077f962dc2e67a0a9ea882535.tar.bz2 rails-834361145a805b5077f962dc2e67a0a9ea882535.zip |
made ConnectionPool#checkout more robust by trying to loot dead threads when pool is empty
Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#1169 state:committed]
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb | 6 |
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 74381437ca..b7d7384548 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb @@ -143,7 +143,11 @@ module ActiveRecord if @queue.wait(@timeout) next else - raise ConnectionTimeoutError, "could not obtain a database connection within #{@timeout} seconds. The pool size is currently #{@size}, perhaps you need to increase it?" + # try looting dead threads + clear_stale_cached_connections! + if @size == @checked_out.size + raise ConnectionTimeoutError, "could not obtain a database connection within #{@timeout} seconds. The pool size is currently #{@size}, perhaps you need to increase it?" + end end end end |