From 20360483eb08cd8dede8cf26cdec8ff17815a324 Mon Sep 17 00:00:00 2001 From: Marlon Nelson Date: Thu, 18 Aug 2016 10:49:53 -0400 Subject: [PATCH] add logging of excessive looping --- lib/activerecord/delay_touching.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/activerecord/delay_touching.rb b/lib/activerecord/delay_touching.rb index f77d33a..f17d1be 100644 --- a/lib/activerecord/delay_touching.rb +++ b/lib/activerecord/delay_touching.rb @@ -60,6 +60,8 @@ def self.call # Apply the touches that were delayed. def self.apply + n = 0 # count loops + nth = (ENV['DELAY_TOUCHING_LOG_LOOP_EVERY'] || 100).to_i begin ActiveRecord::Base.transaction do state.records_by_attrs_and_class.each do |attr, classes_and_records| @@ -68,6 +70,8 @@ def self.apply end end end + n += 1 + Rails.logger.error { "=== DelayTouch::apply: loop count: #{n}"} if n % nth == 0 end while state.more_records? ensure state.clear_records