maintenance: fix db timeouts in regenerate_post_counts!

Disable database timeouts durings daily maintenance. Fixes
`regenerate_post_counts!` timing out. Remove calls to without_timeout
because otherwise it will reenable the timeout when trying to restore
the old timeout (see 97cc873a3f).
This commit is contained in:
evazion
2019-10-01 22:14:15 -05:00
parent 5d90256b24
commit 3096cea2d6
4 changed files with 11 additions and 17 deletions

View File

@@ -8,6 +8,7 @@ module DanbooruMaintenance
end
def daily
ActiveRecord::Base.connection.execute("set statement_timeout = 0")
PostPruner.new.prune!
Upload.prune!
Delayed::Job.where('created_at < ?', 45.days.ago).delete_all
@@ -22,9 +23,7 @@ module DanbooruMaintenance
TagChangeRequestPruner.reject_all
Ban.prune!
ApplicationRecord.without_timeout do
ActiveRecord::Base.connection.execute("vacuum analyze") unless Rails.env.test?
end
ActiveRecord::Base.connection.execute("vacuum analyze") unless Rails.env.test?
rescue Exception => exception
rescue_exception(exception)
end

View File

@@ -1,10 +1,8 @@
class PostPruner
def prune!
Post.without_timeout do
prune_pending!
prune_flagged!
prune_mod_actions!
end
prune_pending!
prune_flagged!
prune_mod_actions!
end
protected

View File

@@ -13,13 +13,12 @@ class SuperVoter < ApplicationRecord
def self.init!
prune!
without_timeout do
report = PostVoteSimilarity.new(User.admins.first.id)
report.calculate_positive(15).each do |element|
unless SuperVoter.where("user_id = ?", element.user_id).exists?
SuperVoter.create(:user_id => element.user_id)
end
report = PostVoteSimilarity.new(User.admins.first.id)
report.calculate_positive(15).each do |element|
unless SuperVoter.where("user_id = ?", element.user_id).exists?
SuperVoter.create(:user_id => element.user_id)
end
end
end

View File

@@ -184,9 +184,7 @@ class TagAlias < TagRelationship
end
def self.update_cached_post_counts_for_all
TagAlias.without_timeout do
execute_sql("UPDATE tag_aliases SET post_count = tags.post_count FROM tags WHERE tags.name = tag_aliases.consequent_name")
end
execute_sql("UPDATE tag_aliases SET post_count = tags.post_count FROM tags WHERE tags.name = tag_aliases.consequent_name")
end
def create_mod_action