mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Remove CachedConnectionPerThread per-thread pooling mechanism in favor of a fixed pool with default maximum of 5 connections
This commit is contained in:
@@ -280,6 +280,7 @@ unless current_adapter?(:SQLServerAdapter, :SybaseAdapter, :OpenBaseAdapter)
|
||||
sleep zzz # block thread 2 for zzz seconds
|
||||
end
|
||||
t1 = Time.now
|
||||
Person.clear_active_connections!
|
||||
end
|
||||
|
||||
b = Thread.new do
|
||||
@@ -287,6 +288,7 @@ unless current_adapter?(:SQLServerAdapter, :SybaseAdapter, :OpenBaseAdapter)
|
||||
t2 = Time.now
|
||||
Person.transaction { yield }
|
||||
t3 = Time.now
|
||||
Person.clear_active_connections!
|
||||
end
|
||||
|
||||
a.join
|
||||
|
||||
@@ -16,12 +16,14 @@ unless %w(FrontBase).include? ActiveRecord::Base.connection.adapter_name
|
||||
|
||||
class PooledConnectionsTest < ActiveRecord::TestCase
|
||||
def setup
|
||||
super
|
||||
@connection = ActiveRecord::Base.remove_connection
|
||||
end
|
||||
|
||||
def teardown
|
||||
ActiveRecord::Base.clear_all_connections!
|
||||
ActiveRecord::Base.establish_connection(@connection)
|
||||
super
|
||||
end
|
||||
|
||||
def checkout_connections
|
||||
|
||||
@@ -296,6 +296,7 @@ if current_adapter?(:PostgreSQLAdapter)
|
||||
topic.approved = !topic.approved?
|
||||
topic.save!
|
||||
end
|
||||
Topic.clear_active_connections!
|
||||
end
|
||||
end
|
||||
|
||||
@@ -331,6 +332,7 @@ if current_adapter?(:PostgreSQLAdapter)
|
||||
dev = Developer.find(1)
|
||||
assert_equal original_salary, dev.salary
|
||||
end
|
||||
Developer.clear_active_connections!
|
||||
end
|
||||
end
|
||||
|
||||
@@ -342,6 +344,7 @@ if current_adapter?(:PostgreSQLAdapter)
|
||||
# Always expect original salary.
|
||||
assert_equal original_salary, Developer.find(1).salary
|
||||
end
|
||||
Developer.clear_active_connections!
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user