Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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) alk authored NZKoz committed
6 activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
View
@@ -143,7 +143,11 @@ def checkout
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
Please sign in to comment.
Something went wrong with that request. Please try again.