fix newrelic handler for statement timeouts

This commit is contained in:
r888888888
2017-11-15 17:00:37 -08:00
parent 2da40dfc2b
commit 9f90799f27
2 changed files with 4 additions and 7 deletions

View File

@@ -141,12 +141,9 @@ class Tag < ApplicationRecord
Post.with_timeout(30_000, nil, {:tags => name}) do
Post.raw_tag_match(name).where("true /* Tag#update_category_post_counts */").find_each do |post|
post.reload
# sometimes a post gets expunged
if post
post.set_tag_counts(false)
args = TagCategory.categories.map {|x| ["tag_count_#{x}",post.send("tag_count_#{x}")]}.to_h.update(:tag_count => post.tag_count)
Post.where(:id => post.id).update_all(args)
end
post.set_tag_counts(false)
args = TagCategory.categories.map {|x| ["tag_count_#{x}",post.send("tag_count_#{x}")]}.to_h.update(:tag_count => post.tag_count)
Post.where(:id => post.id).update_all(args)
end
end
end

View File

@@ -16,7 +16,7 @@ module Danbooru
yield
rescue ::ActiveRecord::StatementInvalid => x
if Rails.env.production?
NewRelic::Agent.notice_error(x, :custom_params => new_relic_params.merge(:user_id => CurrentUser.user.id, :user_ip_addr => CurrentUser.ip_addr))
NewRelic::Agent.notice_error(x, :custom_params => new_relic_params.merge(:user_id => CurrentUser.id, :user_ip_addr => CurrentUser.ip_addr))
end
return default_value
ensure