aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2013-07-22 03:27:57 -0700
committerPiotr Sarnacki <drogus@gmail.com>2013-07-22 03:27:57 -0700
commitbf2161d1abf2d8aa09a7cc36b72cf0da7f6e167c (patch)
tree5fbebe75fd752d9f5ac0652f5419dad7d938a82c /activerecord
parent230d2f84a1877df47d55524e3903fb6d3e4dee75 (diff)
parent0b6c1f082f2112649611c993d39d4471ee1bb530 (diff)
downloadrails-bf2161d1abf2d8aa09a7cc36b72cf0da7f6e167c.tar.gz
rails-bf2161d1abf2d8aa09a7cc36b72cf0da7f6e167c.tar.bz2
rails-bf2161d1abf2d8aa09a7cc36b72cf0da7f6e167c.zip
Merge pull request #11538 from vipulnsward/rescue-exp
rescue from all exceptions in `ConnectionManagement#call`
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG.md14
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb2
-rw-r--r--activerecord/test/cases/connection_management_test.rb4
3 files changed, 17 insertions, 3 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index 8e262b5fd7..7e9ec7ad94 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -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*
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 811749c7fd..cfdcae7f63 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -624,7 +624,7 @@ module ActiveRecord
end
response
- rescue
+ rescue Exception
ActiveRecord::Base.clear_active_connections! unless testing
raise
end
diff --git a/activerecord/test/cases/connection_management_test.rb b/activerecord/test/cases/connection_management_test.rb
index fe1b40d884..df17732fff 100644
--- a/activerecord/test/cases/connection_management_test.rb
+++ b/activerecord/test/cases/connection_management_test.rb
@@ -80,9 +80,9 @@ module ActiveRecord
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