diff options
author | Brent Wheeldon <brent.wheeldon@gmail.com> | 2018-01-12 15:58:04 -0500 |
---|---|---|
committer | Brent Wheeldon <brent.wheeldon@gmail.com> | 2018-03-23 15:53:19 -0400 |
commit | 0a1ed447999d0092e8d0e86729666fc3b4577151 (patch) | |
tree | cf67e13a66869acc5cb10bf8357da272340c3f74 /activerecord/lib | |
parent | 6aa5cf03ea8232180ffbbae4c130b051f813c670 (diff) | |
download | rails-0a1ed447999d0092e8d0e86729666fc3b4577151.tar.gz rails-0a1ed447999d0092e8d0e86729666fc3b4577151.tar.bz2 rails-0a1ed447999d0092e8d0e86729666fc3b4577151.zip |
Prevent deadlocks when waiting for connection from pool.
When a thread that had the load interlock but was blocked waiting to check a connection out of the connection pool but all of the threads using the available connections were blocked waiting to obtain the load interlock an `ActiveRecord::ConnectionTimeoutError` exception was be thrown by the thread waiting for the connection.
When waiting for the connection to check out we should allow loading to proceed to avoid this deadlock.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb | 4 |
1 files changed, 3 insertions, 1 deletions
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 c730584902..be999e7749 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb @@ -188,7 +188,9 @@ module ActiveRecord t0 = Time.now elapsed = 0 loop do - @cond.wait(timeout - elapsed) + ActiveSupport::Dependencies.interlock.permit_concurrent_loads do + @cond.wait(timeout - elapsed) + end return remove if any? |