Skip to content

Commit

Permalink
Cause ActiveRecord::ConnectionTimeoutError even in Rails 7.1.3
Browse files Browse the repository at this point in the history
`acquire_connection` in connection_pool is now smarter in Rails 7.1.3. Even when running existing tests in Rails7.1.3, `ActiveRecord::ConnectionTimeoutError` no longer occurs because a connection can be obtained by `try_to_checkout_new_connection` after reap.
  • Loading branch information
ohbarye committed May 26, 2024
1 parent 5f9a8c9 commit 64b2641
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@

describe "#acquire_connection" do
it "displays connection owners and other threads" do
ActiveRecord::Base.connection_pool.checkout_timeout = 0.001 # no need to delay test suite by waiting the whole full default timeout

Thread.new { sleep 10 } # another thread

expect {
ActiveRecord::Base.connection # Ensure to acquire a connection
Array.new(ActiveRecord::Base.connection_pool.size) do
Thread.new do
ActiveRecord::Base.connection_pool.checkout(0.1)
ActiveRecord::Base.connection_pool.checkout
sleep 0.001
end
end.each(&:join)
}.to raise_error(ActiveRecord::ConnectionTimeoutError)
Expand Down

0 comments on commit 64b2641

Please sign in to comment.