Permalink
Browse files

Merge pull request #11538 from vipulnsward/rescue-exp

rescue from all exceptions in `ConnectionManagement#call`
  • Loading branch information...
2 parents 230d2f8 + 0b6c1f0 commit bf2161d1abf2d8aa09a7cc36b72cf0da7f6e167c @drogus drogus committed Jul 22, 2013
@@ -1,3 +1,17 @@
+* rescue from all exceptions in `ConnectionManagement#call`
+
+ Fixes #11497
+
+ As `ActiveRecord::ConnectionAdapters::ConnectionManagement` middleware does
+ not rescue from Exception (but only from StandardError), the Connection
+ Pool quickly runs out of connections when multiple erroneous Requests come
+ in right after each other.
+
+ Rescuing from all exceptions and not just StandardError, fixes this
+ behaviour.
+
+ *Vipul A M*
+
* `change_column` for PostgreSQL adapter respects the `:array` option.
*Yves Senn*
@@ -624,7 +624,7 @@ def call(env)
end
response
- rescue
+ rescue Exception
ActiveRecord::Base.clear_active_connections! unless testing
raise
end
@@ -80,9 +80,9 @@ def test_active_connections_are_not_cleared_on_body_close_during_test
end
def test_connections_closed_if_exception
- app = Class.new(App) { def call(env); raise; end }.new
+ app = Class.new(App) { def call(env); raise NotImplementedError; end }.new
explosive = ConnectionManagement.new(app)
- assert_raises(RuntimeError) { explosive.call(@env) }
+ assert_raises(NotImplementedError) { explosive.call(@env) }
assert !ActiveRecord::Base.connection_handler.active_connections?
end

0 comments on commit bf2161d

Please sign in to comment.