Skip to content
This repository
Browse code

made ConnectionPool#checkout more robust by trying to loot dead threa…

…ds when pool is empty

Signed-off-by: Michael Koziarski <michael@koziarski.com>

[#1169 state:committed]
  • Loading branch information...
commit 834361145a805b5077f962dc2e67a0a9ea882535 1 parent 21eb18a
Aliaksey Kandratsenka (aka Aliaksei Kandratsenka) authored October 02, 2008 NZKoz committed October 04, 2008
6  activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -143,7 +143,11 @@ def checkout
143 143
             if @queue.wait(@timeout)
144 144
               next
145 145
             else
146  
-              raise ConnectionTimeoutError, "could not obtain a database connection within #{@timeout} seconds.  The pool size is currently #{@size}, perhaps you need to increase it?"
  146
+              # try looting dead threads
  147
+              clear_stale_cached_connections!
  148
+              if @size == @checked_out.size
  149
+                raise ConnectionTimeoutError, "could not obtain a database connection within #{@timeout} seconds.  The pool size is currently #{@size}, perhaps you need to increase it?"
  150
+              end
147 151
             end
148 152
           end
149 153
         end

0 notes on commit 8343611

Please sign in to comment.
Something went wrong with that request. Please try again.