1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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
This commit is contained in:
Matthew Draper 2016-07-06 08:37:26 +09:30
parent 76ce08a493
commit f4159506d6
2 changed files with 9 additions and 0 deletions

View file

@ -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.

View file

@ -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