Skip to content

Commit

Permalink
Use different name for main and thread connection variable.
Browse files Browse the repository at this point in the history
Under JRuby, the updates of the one shared variable interleaved,
causing threads to pick up each others' connections. I'm amazed
this worked on MRI.
  • Loading branch information
headius committed Nov 4, 2016
1 parent 98faa2a commit 2646c10
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions activerecord/test/cases/connection_pool_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,14 @@ def test_active_connection?

def test_checkout_behaviour
pool = ConnectionPool.new ActiveRecord::Base.connection_pool.spec
connection = pool.connection
assert_not_nil connection
main_connection = pool.connection
assert_not_nil main_connection
threads = []
4.times do |i|
threads << Thread.new(i) do
connection = pool.connection
assert_not_nil connection
connection.close
thread_connection = pool.connection
assert_not_nil thread_connection
thread_connection.close
end
end

Expand Down

0 comments on commit 2646c10

Please sign in to comment.