From f4159506d68d7d7781e1534bebbf83c0c3423562 Mon Sep 17 00:00:00 2001 From: Matthew Draper Date: Wed, 6 Jul 2016 08:37:26 +0930 Subject: 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 --- .../lib/active_record/connection_adapters/abstract/connection_pool.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'activerecord/lib/active_record') 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 -- cgit v1.2.3