Hi, intrigeri wrote (09 Feb 2015 15:02:36 GMT) : > Adding the previous maintainers of ruby-activerecord-3.2 into the > loop, in case they have an idea. E.g. would it be an option to > reintroduce the 'verify_active_connections!' method from 3.2 into > Jessie's ActiveRecord::Base:Class? (I guess not, but if it is, then it > would possibly be the easiest way forward.)
I gave this option a try, and failed. Here's what I see in the journal: puppet-master[25887]: ActiveRecord-based storeconfigs and inventory are deprecated. See http://links.puppetlabs.com/activerecord-deprecation puppet-master[25887]: (at /usr/lib/ruby/vendor_ruby/puppet/indirector/facts/active_record.rb:13:in `initialize') puppet-master[25887]: Cached facts for jenkins.lizard failed: wrong number of arguments (2 for 1) puppet-master[25887]: Could not retrieve facts for jenkins.lizard: Couldn't find all Puppet::Rails::FactValues with 'id': (all, {:include=>:fact_name}) [WHERE "fact_values"."host_id" = ?] (found 0 results, but was looking for 2) My Ruby skills are poor, and the affected area (connection pool handling) has seen quite some refactoring since 3.x so it was a bit ambitious for me to try. Perhaps someone who knows Ruby or the Rails codebase better would easily success where I failed :) I'm attaching the patches I've added to debian/patches/, and the resulting debian/patches/series, in case someone wants to try and avoid starting from scratch. Any taker? Cheers, -- intrigeri
From: intrigeri <intrig...@debian.org> Date: Fri, 27 Feb 2015 12:18:56 +0000 Subject: Revert "removes verify_active_connections!" This reverts commit 9d1f1b1ea9e5d637984fda4f276db77ffd1dbdcb. --- .../connection_adapters/abstract/connection_pool.rb | 19 +++++++++++++++++++ activerecord/lib/active_record/connection_handling.rb | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) 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 b459b94..19318c6 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb @@ -332,6 +332,20 @@ module ActiveRecord end end + # Verify active connections and remove and disconnect connections + # associated with stale threads. + def verify_active_connections! #:nodoc: + synchronize do + @connections.each do |connection| + connection.verify! + end + end + end + + def clear_stale_cached_connections! # :nodoc: + end + deprecate :clear_stale_cached_connections! + # Check-out a database connection from the pool, indicating that you want # to use it. You should call #checkin when you no longer need this. # @@ -532,6 +546,11 @@ module ActiveRecord connection_pool_list.each(&:disconnect!) end + # Verify active connections. + def verify_active_connections! #:nodoc: + connection_pools.each_value {|pool| pool.verify_active_connections! } + end + # Locate the connection of the nearest super class. This can be an # active or defined connection: if it is the latter, it will be # opened and set as the active connection for the class it was defined diff --git a/activerecord/lib/active_record/connection_handling.rb b/activerecord/lib/active_record/connection_handling.rb index 8f51590..c00ea57 100644 --- a/activerecord/lib/active_record/connection_handling.rb +++ b/activerecord/lib/active_record/connection_handling.rb @@ -127,6 +127,6 @@ module ActiveRecord end delegate :clear_active_connections!, :clear_reloadable_connections!, - :clear_all_connections!, :to => :connection_handler + :clear_all_connections!, :verify_active_connections!, :to => :connection_handler end end
From: Jonathan Rochkind <jonat...@dnil.net> Date: Mon, 12 Mar 2012 11:14:22 -0400 Subject: deprecated clear_stale_active_connections! can call #reap instead of no-op'ing, #reap does the same thing --- .../lib/active_record/connection_adapters/abstract/connection_pool.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 19318c6..ccec637 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb @@ -343,8 +343,9 @@ module ActiveRecord end def clear_stale_cached_connections! # :nodoc: + reap end - deprecate :clear_stale_cached_connections! + deprecate :clear_stale_cached_connections! => "Please use #reap instead" # Check-out a database connection from the pool, indicating that you want # to use it. You should call #checkin when you no longer need this.
From: intrigeri <intrig...@debian.org> Date: Fri, 27 Feb 2015 12:52:17 +0000 Subject: Adjust reintroduced verify_active_connections! to match new style of this class. This matches what was done upstream on similar methods in commits c3ca7ac and ba1544d. --- .../lib/active_record/connection_adapters/abstract/connection_pool.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 ccec637..53cb2fc 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb @@ -549,7 +549,7 @@ module ActiveRecord # Verify active connections. def verify_active_connections! #:nodoc: - connection_pools.each_value {|pool| pool.verify_active_connections! } + connection_pool_list.each(&:verify_active_connections!) end # Locate the connection of the nearest super class. This can be an
be-carefull-with-that-bundler.patch Revert-removes-verify_active_connections.patch deprecated-clear_stale_active_connections-can-call-r.patch Adjust-reintroduced-verify_active_connections-to-mat.patch