From 0b6c1f082f2112649611c993d39d4471ee1bb530 Mon Sep 17 00:00:00 2001 From: Vipul A M Date: Mon, 22 Jul 2013 01:41:41 +0530 Subject: 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. Recueing from all exceptions and not just StandardError, fixes this behaviour. --- activerecord/test/cases/connection_management_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activerecord/test/cases/connection_management_test.rb') 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 -- cgit v1.2.3 From bd09afb5fb3e2047c605660dac6ef4495c419716 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Fri, 8 Nov 2013 13:57:51 -0200 Subject: Don't skip tests if we don't need to. We can conditional define the tests depending on the adapter or connection. Lets keep the skip for fail tests that need to be fixed. --- .../test/cases/connection_management_test.rb | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'activerecord/test/cases/connection_management_test.rb') diff --git a/activerecord/test/cases/connection_management_test.rb b/activerecord/test/cases/connection_management_test.rb index df17732fff..00667cc52e 100644 --- a/activerecord/test/cases/connection_management_test.rb +++ b/activerecord/test/cases/connection_management_test.rb @@ -26,25 +26,25 @@ module ActiveRecord assert ActiveRecord::Base.connection_handler.active_connections? end - def test_connection_pool_per_pid - return skip('must support fork') unless Process.respond_to?(:fork) + if Process.respond_to?(:fork) + def test_connection_pool_per_pid + object_id = ActiveRecord::Base.connection.object_id - object_id = ActiveRecord::Base.connection.object_id + rd, wr = IO.pipe - rd, wr = IO.pipe + pid = fork { + rd.close + wr.write Marshal.dump ActiveRecord::Base.connection.object_id + wr.close + exit! + } - pid = fork { - rd.close - wr.write Marshal.dump ActiveRecord::Base.connection.object_id wr.close - exit! - } - - wr.close - Process.waitpid pid - assert_not_equal object_id, Marshal.load(rd.read) - rd.close + Process.waitpid pid + assert_not_equal object_id, Marshal.load(rd.read) + rd.close + end end def test_app_delegation -- cgit v1.2.3