diff options
author | Matthew Draper <matthew@trebex.net> | 2016-07-06 08:37:26 +0930 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2016-07-06 08:59:56 +0930 |
commit | f4159506d68d7d7781e1534bebbf83c0c3423562 (patch) | |
tree | c32d24d65bea5321f3e44f50659b5eb314479cd5 /activerecord | |
parent | 76ce08a493fbd9f8c38d719f4c329bc2153204fc (diff) | |
download | rails-f4159506d68d7d7781e1534bebbf83c0c3423562.tar.gz rails-f4159506d68d7d7781e1534bebbf83c0c3423562.tar.bz2 rails-f4159506d68d7d7781e1534bebbf83c0c3423562.zip |
Re-check that the connection is still stale before we reap it
A concurrent thread may have also detected it to be stale, and already
released (or even reassigned) it by now.
Fixes #25585
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/CHANGELOG.md | 7 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb | 2 |
2 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 8521d3b07b..4637847987 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,10 @@ +* Ensure concurrent invocations of the connection reaper cannot allocate the + same connection to two threads. + + Fixes #25585. + + *Matthew Draper* + * Inspecting an object with an associated array of over 10 elements no longer truncates the array, preventing `inspect` from looping infinitely in some cases. 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 c341773be1..51bbc02b0c 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb @@ -561,6 +561,8 @@ module ActiveRecord stale_connections.each do |conn| synchronize do + next unless conn.in_use? && !conn.owner.alive? + if conn.active? conn.reset! checkin conn |